Posts

Showing posts with the label csv

CSV file field re-formating

CSV file field re-formating I have the following data in a CSV file. It has 8 columns. Here is the data: Device,Interface,Description,Average Inbound,Max Inbound,Average Outbound,Max Outbound Router,Cable0/0/0,,34.13M bps,88.57M bps,26.12M bps,80.39M bps Router,Cable0/0/0-upstream0,Node1,10.60M bps,16.07M bps,0 bps,0 bps Router,Cable0/0/0-upstream1,Node1,4.74M bps,13.71M bps,0 bps,0 bps Router,Cable0/0/0-upstream2,Node1,2.14M bps,10.65M bps,0 bps,0 bps Router,Cable0/0/0-upstream3,Node1,1.35M bps,8.33M bps,0 bps,0 bps Router,Cable0/0/1-upstream0,Node2,6.67M bps,7.80M bps,0 bps,0 bps Router,Cable0/0/1-upstream1,Node2,6.40M bps,8.22M bps,0 bps,0 bps Router,Cable0/0/1-upstream2,Node2,5.21M bps,8.06M bps,0 bps,0 bps Router,Cable0/0/1-upstream3,Node2,4.84M bps,7.80M bps,0 bps,0 bps I don't need to do anything with Device column or the Max Inbound or Max Outbound column. However, I need to be able to sum the Avg. Inbound and Avg. Outbound for each Node (Description column). Device Ma...

Importing csv file into mysql database using php

Importing csv file into mysql database using php I have a MS-excel file with a column: Address And a MySQL database table having the columns: Add1, Add2, Add3 Is it possible to break the data in the Address column of Excel file and divide that data into Add1, Add2, Add3 (With Limit of 40 character each column) After uploading the MSExcel file through PHP! My Code For uploading the file in PHP: if(isset($_POST['submit'])) { if(isset($_FILES['uploadFile']['name']) && $_FILES['uploadFile']['name'] != "") { $allowedExtensions = array("xls","xlsx","csv"); $ext = pathinfo($_FILES['uploadFile']['name'], PATHINFO_EXTENSION); if(in_array($ext, $allowedExtensions)) { $file_size = $_FILES['uploadFile']['size'] / 1024; if($file_size < 50) { $file = "../excelfile/".$_FILES['uploadFile']['name']; $isUplo...

JUnit 5 - Convert multiple CSV file parameters into single object

JUnit 5 - Convert multiple CSV file parameters into single object Hello there Java testers. I started working with JUnit 5 a few days ago because I loved the new way of creating parameterized tests. There's the @ParameterizedTest that allows a test to run in a parameterized fashion and @CsvFileSource that loads the parameters from a CSV file. @ParameterizedTest @CsvFileSource The thing is that I have too much columns in my CSV and don't want to have a huge method signature in my unit test. Let me give you an example: @ParameterizedTest @CsvFileSource(resources = "/test-data.csv") void myTest(String p1, String p2, String p3, String p4, String p5, String p6) { //test using parameters } I'd like to know if there's some kind of converter that can do something like this for me: @ParameterizedTest @CsvFileSource(resources = "/test-data.csv") void myTest(@ConvertWith(TestDataConverter.class) TestData testData) { //test using parameters } static cl...

Mysql unable to import csv files

Mysql unable to import csv files I want to clarify that i browse similar questions about file encoding and importing csv files to Mysql. None of these worked for me. The situation is like this: i was in charge of the task of creating a spring boot application which generates csv files filled with random data to populate a database (each csv file correspond to a table in the DB). the first scenario was to import these .csv files into Oracle 12c. There was no problem, i done it, there was no errors in the data. The actual problem is using the same .csv files to import them into Mysql, it is not possible. Clarifying both Databases (Oracle and Mysql) have both the same tables with the equivalent Data Types I tried: Exporting the data from Oracle (from SQLDeveloper) into a .csv file and then import it in Mysql, i got the same error below. the Data Table Import Wizard from Mysql-workbench and it says: Can't analyze file, please try to change encoding type, if that doesn't help, mayb...

Wrong number of values when importing csv in Weka

Wrong number of values when importing csv in Weka I want to open a csv file (saved from openoffice calc) in weka. I keep getting an error: "wrong number of values. 140 read, 139 expected on line 3." The csv was already fixed with quotes around the labels. And I count 140 values on the first lines. What is wrong here? Link to the file. 9 Answers 9 Turns out there was an value somewhere for beyond sight in the excel file I was exporting. I noticed it because all the rows ended with a comma instead of nothing. Carefully selected only the right reach, copied in a document and works. Hope this helps somebody else as well. I had the same error.!!!! I found the solution. Just remove all the double-quote, single-quote from the .csv, .xls file. i,e for eg. under the Name column if the value is "john" it throws an error. Make it to john by removing the quotes. To remove all the quotes, go ...