Skip to main content
Filter by
Sorted by
Tagged with
2450 votes
51 answers
3.4m views

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?
JohnnyM's user avatar
  • 29.6k
1165 votes
10 answers
2.8m views

I have a dataframe in pandas which I would like to write to a CSV file. I am doing this using: df.to_csv('out.csv') And getting the following error: UnicodeEncodeError: 'ascii' codec can't encode ...
user7289's user avatar
  • 34.6k
915 votes
20 answers
1.5m views

I have a comma-separated string that I want to convert into an array, so I can loop through it. Is there anything built-in to do this? For example, I have this string var str = "January,February,...
Blankman's user avatar
  • 269k
827 votes
13 answers
1.4m views

How do I dump a 2D NumPy array into a csv file in a human-readable format?
Dexter's user avatar
  • 11.9k
811 votes
21 answers
1.3m views

How can I write a stored procedure that imports data from a CSV file and populates the table?
vardhan's user avatar
  • 8,119
780 votes
6 answers
910k views

I am trying to save a csv to a folder after making some edits to the file. Every time I use pd.to_csv('C:/Path of file.csv') the csv file has a separate column of indexes. I want to avoid printing ...
Alexis's user avatar
  • 9,241
742 votes
12 answers
931k views

I have a file upload object on my page: <input type="file" ID="fileSelect" /> with the following excel files on my desktop: file1.xlsx file1.xls file.csv I want the file ...
Dom's user avatar
  • 40.7k
715 votes
51 answers
2.3m views

I'm trying to use pandas to manipulate a .csv file but I get this error: pandas.parser.CParserError: Error tokenizing data. C error: Expected 2 fields in line 3, saw 12 I have tried to read the ...
abuteau's user avatar
  • 7,491
653 votes
34 answers
717k views

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 ...
Lyubomyr Shaydariv's user avatar
639 votes
36 answers
664k views

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 ...
user avatar
558 votes
10 answers
3.3m views

I'm trying to read a CSV file into Python (Spyder), but I keep getting an error. My code: import csv data = open("C:\Users\miche\Documents\school\jaar2\MIK\2.6\vektis_agb_zorgverlener") ...
Miesje's user avatar
  • 5,577
516 votes
15 answers
588k views

I'm trying to export a PostgreSQL table with headings to a CSV file via command line, however I get it to export to CSV file, but without headings. My code looks as follows: COPY products_273 to '/...
Elitmiar's user avatar
  • 37.2k
479 votes
7 answers
585k views

I want to know if it is possible to use the pandas to_csv() function to add a dataframe to an existing csv file. The csv file has the same structure as the loaded data.
Ayoub Ennassiri's user avatar
433 votes
18 answers
446k views

What are some command-line CSV viewers for Linux or OSX? I'm thinking of something like less but that spaces out the columns in a more readable way. (I'd be fine with opening it with OpenOffice Calc ...
Benjamin Oakes's user avatar
411 votes
11 answers
519k views

I need to send a CSV file in HTTP response. How can I set the output response as CSV format? This is not working: Response.ContentType = "application/CSV";
balaweblog's user avatar
  • 15.6k
395 votes
12 answers
398k views

I'm looking for a way to convert xlsx files to csv files on Linux. I do not want to use PHP/Perl or anything like that since I'm looking at processing several millions of lines, so I need something ...
user1390150's user avatar
  • 3,959
383 votes
10 answers
246k views

I have a script reading in a csv file with very huge fields: # example from http://docs.python.org/3.3/library/csv.html?highlight=csv%20dictreader#examples import csv with open('some.csv', newline='')...
user1251007's user avatar
361 votes
20 answers
502k views

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 ...
David Pfeffer's user avatar
348 votes
39 answers
570k views

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 ...
User1's user avatar
  • 41.6k
339 votes
7 answers
365k views

I have a line like this in my CSV: "Samsung U600 24"","10000003409","1","10000003427" Quote next to 24 is used to express inches, while the quote just next to that quote closes the field. I'm ...
srgb's user avatar
  • 5,293
331 votes
26 answers
996k views

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 = ...
little_fish's user avatar
  • 4,389
322 votes
13 answers
512k views

I have a situation wherein sometimes when I read a csv from df I get an unwanted index-like column named unnamed:0. file.csv ,A,B,C 0,1,2,3 1,4,5,6 2,7,8,9 The CSV is read with this: pd.read_csv('...
Collective Action's user avatar
296 votes
7 answers
895k views

I am reading a csv file into pandas. This csv file consists of four columns and some rows, but does not have a header row, which I want to add. I have been trying the following: Cov = pd.read_csv(&...
sequence_hard's user avatar
292 votes
15 answers
545k views

Where could I find some JavaScript code to parse CSV data?
Pierre-Gilles Levallois's user avatar
275 votes
16 answers
1.1m views

I am trying to write into a csv file row by row using C# language. Here is my function string first = reader[0].ToString(); string second=image.ToString(); string csv = string.Format("{0},{1}\n", ...
rampuriyaaa's user avatar
  • 5,156

1
2 3 4 5
1809