csv

improving data extraction from text file in Java

I have CSV file with sample data in this form : 220 30 255 0 0 Javascript 200 20 0 255 128 Thinking in java , where the first column is height, second thickness, next three are rgb values for color and last one is title. All need to be treated as separate variables. I have already written my own solution for this, ...

How to read CSV file using c#

Hello All, I am reading csv file and creating dataset. string MyPath = System.IO.Path.GetDirectoryName(Filename); string ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + MyPath + ";Extended Properties='text;HDR=Yes;FMT=Delimited'"; //string CmdText = "select * from JDL-NurseryParts" + System.IO.Path.GetFileName(File...

DBD::CSV: Problem with file-name-extensions

In this script I have problems with file-name-extensions: if I use /home/mm/test_x it works, with file named /home/mm/test_x.csv it doesn't: #!/usr/bin/env perl use warnings; use strict; use 5.012; use DBI; my $table_1 = '/home/mm/test_1.csv'; my $table_2 = '/home/mm/test_2.csv'; #$table_1 = '/home/mm/test_1'; #$table_2 = '/home/mm/tes...

XSLt.transform gives me ""

Hi, I have XML: <results> <Countries country="Albania"> <Regions region="Centralna Albania"> <Provinces province="Durres i okolice"> <Cities city="Durres" cityCode="2B66E0ACFAEF78734E3AF1194BFA6F8DEC4C5760"> <IndividualFlagsWithForObjects Status="1...

How to programmatically guess whether a CSV file is comma or semicolon delimited

In most cases, CSV files are text files with records delimited by commas. However, sometimes these files will come semicolon delimited. (Excel will use semicolon delimiters when saving CSVs if the regional settings has the decimal separator set as the comma -- this is common in Europe. Ref: http://en.wikipedia.org/wiki/Comma-separate...

In DBD::CSV what does a /r in the f_ext attribute mean?

Why does only the second example append the extension to the filename and what is the "/r" in ".csv/r" for. #!/usr/bin/env perl use warnings; use strict; use 5.012; use DBI; my $dbh = DBI->connect( "DBI:CSV:f_dir=/home/mm", { RaiseError => 1, f_ext => ".csv/r"} ); my $table = 'new_1'; $dbh->do( "DROP TABLE IF EXISTS $table" ); $dbh->d...

DBD::CSV: Problem with userdefined functions

From the SQL::Statement::Functions documentation: Creating User-Defined Functions ... More complex functions can make use of a number of arguments always passed to functions automatically. Functions always receive these values in @_: sub FOO { my( $self, $sth, $rowhash, @params ); } #!/usr/bin/env perl use 5.012; use warning...

Pyparsing CSV string with random quotes

Hey, I have a string like the following: <118>date=2010-05-09,time=16:41:27,device_id=FE-2KA3F09000049,log_id=0400147717,log_part=00,type=statistics,subtype=n/a,pri=information,session_id=o49CedRc021772,from="[email protected]",mailer="mta",client_name="example.org,[194.177.17.24]",resolved=OK,to="[email protected]"...

How to change particular column entries in a mysql table when uploading data from csv file?

I upload data into a mysql table from csv file in a standard way like this: TRUNCATE TABLE table_name; load data local infile '/path/to/file/file_name.csv' into table table_name fields terminated by ',' enclosed by '"' lines terminated by '\r\n' (id, name, type, deleted); All 'deleted' column entries in csv file has either 'current' o...

How to format a datetime so that Excel will understand it?

I have a script which outputs a CSV file. How should I format dates or date+time fields so that Excel will correctly parse that field as a date? PS: I'd like to keep timezone information intact as well. ...

DBD::CSV: How can I generate different behavior with the two f_ext-options ".csv" and ".csv/r"?

This is from the DBD::File-documentation: f_ext This attribute is used for setting the file extension where (CSV) files are opened. There are several possibilities. DBI:CSV:f_dir=data;f_ext=.csv In this case, DBD::File will open only table.csv if both table.csv and table exist in the datadir. The table will still b...

R - Specifying colClasses in the read.csv

Hi, I am trying to specify the colClasses options in the read.csv function in R. In my data, the first column "time" is basically a character vector while the rest of the columns are numeric. data<-read.csv("test.csv" , comment.char="" , colClasses=c(time="character","numeric") , strip.white=FALSE) In the above command, I would want ...

how to extract data from csv file in php

I have a csv file which looks like this $lines[0] = "text, with commas", "another text", 123, "text",5; $lines[1] = "some without commas", "another text", 123, "text"; $lines[2] = "some text with commas or no",, 123, "text"; And I would like to have a table: $t[0] = array("text, with commas", "another text", "123", "text","5"); $t[1]...

SUPER CSV write bean to CSV.

Here is my class, public class FreebasePeopleResults { public String intendedSearch; public String weight; public Double heightMeters; public Integer age; public String type; public String parents; public String profession; public String alias; public String children; public String siblings; public String spouse; public String degree;...

Writing csv header removes data from numpy array written below

I'm trying to export data to a csv file. It should contain a header (from datastack) and restacked arrays with my data (from datastack). One line in datastack has the same length as dataset. The code below works but it removes parts of the first line from datastack. Any ideas why that could be? s = ','.join(itertools.chain(dataset)) + ...

MySQL bulk insert from CSV data files

I have some CSV data files that I want to import into mySQL. I would like to do the insert in a shell script, so that it can be automated. However, I am a bit weary of having the username and password in clear text in the script I have the following questions: I am uncomfortable with the idea of a uname/pwd in clear text in the scrip...

How to use PHP fgetcsv to create an array for each piece of data in csv file?

I'm trying to import data from a csv file to some html code to use it in a graph I have already coded. I'm trying to use PHP and fgetcsv to create arrays for each separate piece of data to use PHP to put it into the html code. I know how to open the csv file and to print it using PHP, and how to print each separate row, but not each piec...

Ignore first line on csv parse Rails

Hi, I am using the code from this tutorial to parse a CSV file and add the contents to a database table. How would I ignore the first line of the CSV file? The controller code is below: def csv_import @parsed_file=CSV::Reader.parse(params[:dump][:file]) n = 0 @parsed_file.each do |row| s = Student.new s.name = row[0] ...

MySQL: Blank row in table after LOAD DATA INFILE

Hi, I'm uploading a large amount of data from a CSV (I'm doing it via MySQL Workbench): LOAD DATA INFILE 'C:/development/mydoc.csv' INTO TABLE mydatabase.mytable CHARACTER SET utf8 FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\r'; However, I'm noticing that it keeps adding an empty line full of nulls/zeros...

How can I join on a CSV varchar?

I have a varchar field that contains a string like "10,11,12,13". How can I use that CSV string to join to another table with those IDs? Here's the approach I'm taking now: select * from SomeTable a WHERE (',' + @csvString + ',') LIKE '%,' + CONVERT(varchar(25), a.ID) + ',%' Where @csvString is "10,11,12,...". I intend to use this ...