Questions tagged [csv]
Comma-Separated Values or Character-Separated Values (CSV) is a common "flat file database" (or spreadsheet-style) format for storing tabular data in plain text, with fields separated by a special character (comma, tab, etc). Rows are typically denoted by newline characters. Use for any delimited file formats, including tab delimited (TSV)
7,877
questions
2424
votes
48
answers
3.3m
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:
Peter
Paul
Mary
Is there an easy way to turn this into a single string of Peter, Paul, Mary?
340
votes
39
answers
540k
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 ...
338
votes
18
answers
741k
views
Turning a Comma Separated string into individual rows
I have a SQL Table like this:
SomeID
OtherID
Data
abcdef-.....
cdef123-...
18,20,22
abcdef-.....
4554a24-...
17,19
987654-.....
12324a2-...
13,19,20
Is there a query where I can perform a query ...
768
votes
20
answers
987k
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
...
192
votes
38
answers
1.3m
views
How to split a comma-separated value to columns
I have a table like this
Value
String
1
Cleo, Smith
I want to separate the comma delimited string into two columns
Value
Name
Surname
1
Cleo
Smith
I need only two fixed extra columns
48
votes
8
answers
18k
views
What's the most robust way to efficiently parse CSV using awk?
Given a CSV as might be generated by Excel or other tools with embedded newlines and/or double quotes and/or commas in fields, and empty fields like:
$ cat file.csv
"rec1, fld1",,"rec1&...
133
votes
13
answers
303k
views
SQL split values to multiple rows
I have table :
id | name
1 | a,b,c
2 | b
i want output like this :
id | name
1 | a
1 | b
1 | c
2 | b
322
votes
16
answers
545k
views
How do I read a large csv file with pandas?
I am trying to read a large csv file (aprox. 6 GB) in pandas and i am getting a memory error:
MemoryError Traceback (most recent call last)
<ipython-input-58-...
102
votes
9
answers
125k
views
How do I read and write CSV files?
How do I read the following CSV file?
1,"A towel,",1.0
42," it says, ",2.0
1337,is about the most ,-1
0,massively useful thing ,123
-2,an interstellar hitchhiker can have.,3
How ...
357
votes
20
answers
484k
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 ...
731
votes
11
answers
568k
views
CSV file written with Python has blank lines between each row
import csv
with open('thefile.csv', 'rb') as f:
data = list(csv.reader(f))
import collections
counter = collections.defaultdict(int)
for row in data:
counter[row[10]] += 1
with open(...
288
votes
15
answers
526k
views
How to parse CSV data?
Where could I find some JavaScript code to parse CSV data?
535
votes
29
answers
660k
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 ...
638
votes
34
answers
695k
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 ...
320
votes
26
answers
937k
views
How can I convert JSON to CSV?
I have a JSON file I want to convert to a CSV file. How can I do this with Python?
I tried:
import json
import csv
f = open('data.json')
data = json.load(f)
f.close()
f = open('data.csv')
csv_file = ...