Questions tagged [csv]

Comma-Separated Values or Character-Separated Values (CSV) is a standard "flat file database" format for storing tabular data in plain text, consisting of an optional header row that lists the table fields delimited by commas or tabs or other delimiter character, followed by one or more rows (...

1548
votes
44answers
1.9m views

How to concatenate text from multiple rows into a single text string in SQL server?

Consider a database table holding names, with three rows:PeterPaulMaryIs there an easy way to turn this into a single string of Peter, Paul, Mary?
205
votes
31answers
263k views

How can I read and parse CSV files in C++?

I need to load and use CSV file data in C++. At this point it can really just be a comma-delimited parser (ie don't worry about escaping new lines and commas). The main need is a line-by-line parser ...
92
votes
31answers
701k views

How to split a comma-separated value to columns

I have a table like thisValue String-------------------1 Cleo, SmithI want to separate the comma delimited string into two columnsValue Name Surname-------------------1 Cleo ...
133
votes
13answers
218k views

How to import multiple .csv files at once?

Suppose we have a folder containing multiple data.csv files, each containing the same number of variables but each from different times.Is there a way in R to import them all simultaneously rather ...
421
votes
22answers
461k views

Dealing with commas in a CSV file

I am looking for suggestions on how to handle a csv file that is being created, then uploaded by our customers, and that may have a comma in a value, like a company name.Some of the ideas we are ...
187
votes
8answers
262k views

Javascript code to parse CSV data [duplicate]

Does someone have an idea on where I could find some javascript code to parse CSV data ?
211
votes
16answers
248k views

Parsing CSV files in C#, with header

Is there a default/official/recommended way to parse CSV files in C#? I don't want to roll my own parser.Also, I've seen instances of people using ODBC/OLE DB to read CSV via the Text driver, and a ...
153
votes
10answers
195k views

CSV API for Java [closed]

Can anyone recommend a simple API that will allow me to use read a CSV input file, do some simple transformations, and then write it.A quick google has found http://flatpack.sourceforge.net/ which ...
958
votes
28answers
947k views

How to output MySQL query results in CSV format?

Is there an easy way to run a MySQL query from the Linux command line and output the results in CSV format?Here's what I'm doing now:mysql -u uid -ppwd -D dbname << EOQ | sed -e 's/ /...
140
votes
10answers
184k views

Reading CSV files using C#

I'm writing a simple import application and need to read a CSV file, show result in a DataGrid and show corrupted lines of the CSV file in another grid. For example, show the lines that are shorter ...
371
votes
22answers
371k views

How to export JavaScript array info to csv (on client side)?

I know there are lot of questions of this nature but I need to do this using JavaScript. I am using Dojo 1.8 and have all the attribute info in array, which looks like this:[["name1", "city_name1", ....
231
votes
15answers
734k views

How to import CSV file to MySQL table

I have an unnormalized events-diary CSV from a client that I'm trying to load into a MySQL table so that I can refactor into a sane format. I created a table called 'CSVImport' that has one field for ...
326
votes
24answers
390k views

Is it possible to force Excel recognize UTF-8 CSV files automatically?

I'm developing a part of an application that's responsible for exporting some data into CSV files. The application always uses UTF-8 because of its multilingual nature at all levels. But opening such ...
122
votes
17answers
284k views

How can I convert JSON to CSV?

I have a JSON file that I want to covert to a CSV file. How can I do this with Python?I tried:import jsonimport csvf=open('data.json')data=json.load(f)f.close()f=open('data.csv')...
488
votes
13answers
635k views

How to import CSV file data into a PostgreSQL table?

How can I write a stored procedure that imports data from a CSV file and populates the table?
95
votes
9answers
99k views

How to read a 6 GB csv file with pandas

I am trying to read a large csv file (aprox. 6 GB) in pandas and i am getting the following memory error:MemoryError Traceback (most recent call last)<ipython-input-...
242
votes
6answers
134k views

CSV file written with Python has blank lines between each row

import csvwith open('thefile.csv', 'rb') as f:data=list(csv.reader(f))import collectionscounter=collections.defaultdict(int)for row in data:counter[row[10]] +=1with open(...
23
votes
3answers
21k views

How do I read and write CSV files with Python?

I have a file example.csv with the contents1,"A towel,",1.042," it says, ",2.01337,is about the most ,-10,massively useful thing ,123-2,an interstellar hitchhiker can have.,3How do I read this ...
175
votes
22answers
129k views

Microsoft Excel mangles Diacritics in .csv files?

I am programmatically exporting data (using PHP 5.2) into a .csv test file.Example data: Numéro 1 (note the accented e).The data is utf-8 (no prepended BOM).When I open this file in MS Excel is ...
159
votes
30answers
271k views

How can I output a UTF-8 CSV in PHP that Excel will read properly?

I've got this very simple thing that just outputs some stuff in CSV format, but it's got to be UTF-8. I open this file in TextEdit or TextMate or Dreamweaver and it displays UTF-8 characters properly, ...
437
votes
34answers
398k views

Stop Excel from automatically converting certain text values to dates

Does anyone happen to know if there is a token I can add to my csv for a certain field so Excel doesn't try to convert it to a date?I'm trying to write a .csv file from my application and one of the ...
128
votes
7answers
254k views

Export to CSV via PHP

Let's say I have a database.... is there a way I can export what I have from the database to a CSV file (and text file [if possible]) via PHP?
99
votes
18answers
208k views

Parsing a comma-delimited std::string [duplicate]

If I have a std::string containing a comma-separated list of numbers, what's the simplest way to parse out the numbers and put them in an integer array?I don't want to generalise this out into ...
101
votes
12answers
91k views

How to read data when some numbers contain commas as thousand separator?

I have a csv file where some of the numerical values are expressed as strings with commas as thousand separator, e.g. "1,513" instead of 1513. What is the simplest way to read the data into R?I can ...
67
votes
8answers
62k views

How to split csv whose columns may contain ,

Given2,1016,7/31/2008 14:22,Geoff Dalgas,6/5/2011 22:21,http://stackoverflow.com,"Corvallis, OR",7679,351,81,b437f461b3fd27387c5d8ab47a293d35,34How to use C# to split the above ...
531
votes
36answers
676k views

Excel to CSV with UTF8 encoding

I have an Excel file that has some Spanish characters (tildes, etc.) that I need to convert to a CSV file to use as an import file. However, when I do Save As CSV it mangles the "special" Spanish ...
143
votes
17answers
308k views

How to read a CSV file into a .NET Datatable

How can I load a CSV file into a System.Data.DataTable, creating the datatable based on the CSV file?Does the regular ADO.net functionality allow this?
44
votes
8answers
58k views

Can you recommend a Java library for reading (and possibly writing) CSV files? [closed]

Can you recommend a Java library for reading, parsing, validating and mapping rows in a comma separated value (CSV) file to Java value objects (JavaBeans)?
17
votes
1answer
2k views

What's the most robust way to efficiently parse CSV using awk?

The intent of this question is to provide a canonical answer.Given a CSV as might be generated by Excel or other tools with embedded newlines, embedded double quotes and empty fields like:$ cat ...
65
votes
4answers
103k views

XML to CSV Using XSLT

I have the following XML document:<projects><project><name>Shockwave</name> <language>Ruby</language> <owner>Brian May</owner> <...
13
votes
10answers
39k views

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 ...
236
votes
17answers
629k views

Reading CSV file and storing values into an array

I am trying to read a *.csv-file.The *.csv-file consist of two columns separated by semicolon (";"). I am able to read the *.csv-file using StreamReader and able to separate each line by using the ...
711
votes
14answers
520k views

Save PL/pgSQL output from PostgreSQL to a CSV file

What is the easiest way to save PL/pgSQL output from a PostgreSQL database to a CSV file? I'm using PostgreSQL 8.4 with pgAdmin III and PSQL plugin where I run queries from.
80
votes
7answers
132k views

Reading a UTF8 CSV file with Python

I am trying to read a CSV file with accented characters with Python (only French and/or Spanish characters). Based on the Python 2.5 documentation for the csvreader (http://docs.python.org/library/csv....
190
votes
8answers
168k views

Import multiple csv files into pandas and concatenate into one DataFrame

I would like to read several csv files from a directory into pandas and concatenate them into one big DataFrame. I have not been able to figure it out though. Here is what I have so far:import glob...
204
votes
20answers
318k views

Create a CSV File for a user in PHP

I have data in a MySQL database. I am sending the user a URL to get their data out as a CSV file.I have the e-mailing of the link, MySQL query, etc. covered.How can I, when they click the link, ...
109
votes
9answers
407k views

Python - Write to Excel Spreadsheet

I am new to Python. I need to write some data from my program to a spreadsheet. I've searched online and there seems to be many packages available (xlwt, XlsXcessive, openpyxl). Others suggest to ...
87
votes
13answers
207k views

Convert XLS to CSV on command line

How could I convert an XLS file to a CSV file on the windows command line.The machine has Microsoft Office 2000 installed. I'm open to installing OpenOffice if it's not possible using Microsoft ...
125
votes
7answers
355k views

Read specific columns from a csv file with csv module?

I'm trying to parse through a csv file and extract the data from only specific columns.Example csv:ID | Name | Address | City | State | Zip | Phone | OPEID | IPEDS |10 | C... | 130 W.. | Mo.. | ...
88
votes
6answers
61k views

CSV parser/reader for C#? [closed]

is there a good and free implementation of CSV parser available under some liberal licence? Some counterpart of SuperCSV for Java, perhaps a port?
60
votes
10answers
217k views

Convert multiple rows into one with comma as separator [duplicate]

If I issue SELECT username FROM Users I get this result:username--------PaulJohnMarybut what I really need is one row with all the values separated by comma, like this:Paul, John, MaryHow ...
128
votes
13answers
476k views

How do I spool to a CSV formatted file using SQLPLUS?

I want to extract some queries to a CSV output format. Unfortunately, I can't use any fancy SQL client or any language to do it. I must use SQLPLUS.How do I do it?
77
votes
8answers
103k views

Importing a CSV file into a sqlite3 database table using Python

I have a CSV file and I want to bulk-import this file into my sqlite3 database using Python. the command is ".import .....". but it seems that it cannot work like this. Can anyone give me an example ...
104
votes
10answers
333k views

How to export data as CSV format from SQL Server using sqlcmd?

I can quite easily dump data into a text file such as:sqlcmd -S myServer -d myDB -E -Q "select col1, col2, col3 from SomeTable" -o "MyData.txt"However, I have looked at the help files for ...
113
votes
6answers
200k views

PHP code to convert a MySQL query to CSV [closed]

What is the most efficient way to convert a MySQL query to CSV in PHP please?It would be best to avoid temp files as this reduces portability (dir paths and setting file-system permissions required)....
32
votes
2answers
110k views

How do i download a file using VBA (Without internet explorer)

I need to download a CSV file from a website using VBA in Excel. The server also needed to authenticate me since it was data from a survey service.I found a lot of examples using Internet Explorer ...
67
votes
7answers
89k views

Write single CSV file using spark-csv

I am using https://github.com/databricks/spark-csv , I am trying to write a single CSV, but not able to, it is making a folder.Need a Scala function which will take parameter like path and file name ...
67
votes
6answers
144k views

Export to CSV using jQuery and html

I have a tabular data which I need to export to csv without using any external plugin or api. I used the window.open method passing the mime types but faced issues like below:How to determine ...
76
votes
9answers
283k views

MYSQL import data from csv using LOAD DATA INFILE

I am importing some data of 20000 rows from a CSV file into Mysql.Columns in the CSV are in a different order than MySQL table's columns. How to automatically assign columns corresponding to Mysql ...
141
votes
3answers
164k views

Skip the headers when editing a csv file using Python

I am using below referred code to edit a csv using Python. Functions called in the code form upper part of the code. Problem: I want the below referred code to start editing the csv from 2nd row, I ...

153050per page
angop.ao, elkhabar.com, noa.al, afghanpaper.com, bbc.com, time.com, cdc.gov, nih.gov, xnxx.com, github.com,