export-to-csv

Python - Reading and writing csv files with utf-8 encoding

我的未来我决定 提交于 2021-02-07 13:37:16
问题 I'm trying to read a csv file the its header contains foreign characters and I'm having a lot of problems with this. first of all, I'm reading the file with a simple csv.reader filename = 'C:\\Users\\yuval\\Desktop\\בית ספר\\עבודג\\new\\resources\\mk'+ str(mkNum) + 'Data.csv' raw_data = open(filename, 'rt', encoding="utf8") reader = csv.reader(raw_data, delimiter=',', quoting=csv.QUOTE_NONE) x = list(reader) header = x[0] data = np.array(x[1:]).astype('float') The var header should be an

Python - Reading and writing csv files with utf-8 encoding

做~自己de王妃 提交于 2021-02-07 13:36:43
问题 I'm trying to read a csv file the its header contains foreign characters and I'm having a lot of problems with this. first of all, I'm reading the file with a simple csv.reader filename = 'C:\\Users\\yuval\\Desktop\\בית ספר\\עבודג\\new\\resources\\mk'+ str(mkNum) + 'Data.csv' raw_data = open(filename, 'rt', encoding="utf8") reader = csv.reader(raw_data, delimiter=',', quoting=csv.QUOTE_NONE) x = list(reader) header = x[0] data = np.array(x[1:]).astype('float') The var header should be an

Export to CSV file and open in browser

流过昼夜 提交于 2021-02-07 11:56:17
问题 I am stuck with an issue where I need to export data to a .csv file, but not store the file in file system - instead I need to simply open the file in browser. I have written the below code to write data to .csv file: FileWriter myWriter = new FileWriter("output.csv"); myWriter.append(EmployeeCode); myWriter.append(','); myWriter.append(Band); myWriter.append('\n'); response.setHeader("Content-Disposition", "attachment; filename=output.csv"); response.setContentType("application/ms-excel");

Can write to csv file but not append

北战南征 提交于 2021-02-05 10:28:22
问题 string pathDesktop = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); string filePath = pathDesktop + "\\mycsvfile.csv"; string delimter = ","; string a = "Enoelpro---[037,033,0,018,030,012,004,021,009,038,035,053,044,050,074,F,018,010,070,000]<Vulpix>[-][037,034,0,022,020,029,002,008,024,036,046,049,041,057,077,F,018,005,070,000]<Vulpix>[-] cual es mejor??"; List<string[]> test = conv(a,"testrainer"); int length = test.Count; using (TextWriter writer = File.CreateText(filePath))

Can write to csv file but not append

爷,独闯天下 提交于 2021-02-05 10:28:22
问题 string pathDesktop = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); string filePath = pathDesktop + "\\mycsvfile.csv"; string delimter = ","; string a = "Enoelpro---[037,033,0,018,030,012,004,021,009,038,035,053,044,050,074,F,018,010,070,000]<Vulpix>[-][037,034,0,022,020,029,002,008,024,036,046,049,041,057,077,F,018,005,070,000]<Vulpix>[-] cual es mejor??"; List<string[]> test = conv(a,"testrainer"); int length = test.Count; using (TextWriter writer = File.CreateText(filePath))

Convert json array with values only to csv using jq

帅比萌擦擦* 提交于 2021-01-29 08:24:20
问题 I have a below JSON and I need to convert it to a CSV. The problem I'm having is that those values have no key. Ideally I would like CSV to look like this, I just don't know how to do it using jq. CSV year;points;surname;name;point1;points2;points3;city;district;url 2020;54;Smith;John;;;London;Waterloo;URL 2015;380;Helen;Smith;;;New York;Manhattan;URL JSON { "draw": 0, "total": "44", "filtered": "8", "data": [ [ "2020", "54", "Smith ", "John", "", "", "", "London", "Waterloo", "URL" ], [

Exporting large number to csv from R

[亡魂溺海] 提交于 2021-01-29 08:19:00
问题 I came across a strange problem when trying to export an R dataframe to a csv file. The dataframe contains some big numbers, but when they are written to the csv file, they "lose" the decimal part and are instead written without it. But not like one would expect, but like this: Say 3224571816.5649 is the correct value in R. When written to csv, it becomes 32245718165649. I am using the write.csv2 function to write the csv. The separators are correct, as it works normally for smaller values.

Automatically scheduling SQL query results to be exported to a csv file

孤街浪徒 提交于 2021-01-29 07:52:55
问题 I have tried to read up on this topic and I am still a bit unclear how to proceed. This seemed like a fairly basic task but it has been nowhere as simple as I had assumed. I have several SQL queries written and I want to be able to schedule them to run on a certain day each month and then automatically be exported to a .csv file in a selected folder. This will then allow them to be automatically uploaded into a BI and reporting tool that our firm uses (this part I know how to take care of). I

How to automatically change the format or encode the excel cell value while writing it to CSV file

北城余情 提交于 2021-01-28 09:01:31
问题 My script is breaking when excel cell has double quotes in their value and quotes. I had to explicitly write a function to handle commas in OUTFILE. Is there any way I can provide cell value and automatically it can be encoded to CSV format. example- cell->value - Student GOT 8 MARKS in math, 7 in Spanish Desired Correct CSV format-> "Student GOT 8 MARKS in math, 7 in Spanish". cell->value - Student GOT 8 MARKS in "math", 7 in "Spanish" Desired Correct CSV format-> "Student GOT 8 MARKS in "

How to create a csv file in Python, and export (put) it to some local directory

不打扰是莪最后的温柔 提交于 2021-01-27 05:58:30
问题 This problem may be tricky. I want to create a csv file from a list in Python. This csv file does not exist before. And then export it to some local directory. There is no such file in the local directory either. We just create a new csv file, and export (put) the csv file in some local directory. I found that StringIO.StringIO can generate the csv file from a list in Python, then what are the next steps. Thank you. And I found the following code can do it: import os import os.path import