export-to-csv

Calling a stored procedure within a stored procedure

天大地大妈咪最大 提交于 2019-11-29 11:33:31
I am trying to call a function within a function using sql on postgres 9.3. This question is related to another post by me . I have written the below function. So far I have failed to incorporate any kind of save-output (COPY) statement, so I am trying to work around this by creating a nested function print-out function. CREATE FUNCTION retrieve_info(TEXT, TEXT) RETURNS SETOF retrieve_info_tbl AS $$ SELECT tblA.id, tblA.method, tblA.species, tblA.location FROM tblA WHERE method=$1 AND species=$2 GROUP BY id, method, species ORDER BY location $$ LANGUAGE 'sql'; The above function works. An

How to write a value which contain comma to a CSV file in c#?

China☆狼群 提交于 2019-11-29 11:22:46
问题 I am using a data table for storing data. I am exporting the data from data table to CSV file. Sometimes there may be values containing comma( , ) so the values are not exported correctly. For Example Consider the value is "9,11,32" . I have to export as such. But when I do the first column conatins 9 then in next column 11 . I want to display 9,11,32 in the same column in the CSV file. How do I do that? 回答1: Simply put your data inside the backslash like this: "\"" + yourdata + "\"". Take a

SQL query output to .csv

家住魔仙堡 提交于 2019-11-29 08:58:17
I am running SQL query from python API and want to collect data in Structured(column-wise data under their header).CSV format. This is the code so far I have. sql = "SELECT id,author From researches WHERE id < 20 " cursor.execute(sql) data = cursor.fetchall() print (data) with open('metadata.csv', 'w', newline='') as f_handle: writer = csv.writer(f_handle) header = ['id', 'author'] writer.writerow(header) for row in data: writer.writerow(row) Now the data is being printed on the console but not getting in .CSV file this is what I am getting as output : What is that I am missing? t.Chovatia

Export sheet as UTF-8 CSV file (using Excel-VBA)

落爺英雄遲暮 提交于 2019-11-29 08:25:46
I would like to export a file I have created in UTF-8 CSV using VBA. From searching message boards, I have found the following code that converts a file to UTF-8 ( from this thread ): Sub SaveAsUTF8() Dim fsT, tFileToOpen, tFileToSave As String tFileToOpen = InputBox("Enter the name and location of the file to convert" & vbCrLf & "With full path and filename ie. C:\MyFolder\ConvertMe.Txt") tFileToSave = InputBox("Enter the name and location of the file to save" & vbCrLf & "With full path and filename ie. C:\MyFolder\SavedAsUTF8.Txt") tFileToOpenPath = tFileToOpen tFileToSavePath = tFileToSave

My csv export displaying html, how to get rid of?

拥有回忆 提交于 2019-11-29 05:18:36
I've seen this asked before and I am having trouble getting this to work properly after trying a number of solutions. The problem is I can't get my data to export into a csv format properly. Before I added my ob_end_clean it would export out to a csv with html, now it doesn't give me a csv, just text. Here is my code on the file that is being required. if (isset($_POST["hidden"])) { $list = array ( array('aaa', 'bbb', 'ccc', 'dddd'), array('123', '456', '789'), array('"aaa"', '"bbb"') ); $fp = fopen('php://output','w'); foreach ($list as $row) { ob_end_clean(); fputcsv($fp, $row); } header(

How to export the resulting data in PostgreSQL to .CSV?

微笑、不失礼 提交于 2019-11-29 04:51:23
I use PostgreSQL 9.4.1 My query: copy(select * from city) to 'C:\\temp\\city.csv' copy(select * from city) to E'C:\\temp\\city.csv' ERROR: relative path not allowed for COPY to file ********** Error ********** ERROR: relative path not allowed for COPY to file SQL state: 42602 As with this case , it seems likely that you are attempting to use copy from a computer other than the one which hosts your database. copy does I/O from the database host machine's local file system only. If you have access to that filesystem, you can adjust your attempt accordingly. Otherwise, you can use the \copy

Set File_Path for to_csv() in Pandas

自作多情 提交于 2019-11-29 00:08:54
问题 funded=r'C:\Users\hill\Desktop\wheels\Leads(1).csv' funded= read_csv(funded) funded=DataFrame(funded) path='C:\Users\hvill\Destop\ ' funded.to_csv(path,'greenl.csv') I want to have a variable that I can set the path in to_csv to. I tried path_or_buf = path. That doesn't work either. 回答1: You need to either escape your back slashes or better use a raw string: path='C:\\Users\\hvill\\Destop\\' or better as fewer characters: path=r'C:\Users\hvill\Destop\' I also think you want to do this when

Export to csv/excel from kibana

落花浮王杯 提交于 2019-11-28 23:40:45
问题 I am building a proof of concept using Elasticsearch Logstash and Kibana for one of my projects. I have the dashboard with the graphs working without any issue. One of the requirements for my project is the ability to download the file(csv/excel). In kibana the only option i saw for downloading the file is by clicking on edit button on the visualization created. Is it possible to add a link on the dashboard that would allow users to download the file without going into the edit mode. And

how to export Core Data to CSV

自作多情 提交于 2019-11-28 19:56:47
I will like to use CHCSVParser to export my Core data to CSV. I know how to get all the value from entity, but I don't know how to write to CSV. Can anybody teach me how to write to CSV with CHCSVParser ? // Test listing all Infos from the store NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; NSEntityDescription *entity = [NSEntityDescription entityForName:@"NoteLog" inManagedObjectContext:context]; [fetchRequest setEntity:entity]; NSArray *fetchedObjects = [context executeFetchRequest:fetchRequest error:&error]; for (NoteLog *noteInfo in fetchedObjects) { NSLog(@"Name: %@",

How to export data from Spark SQL to CSV

时间秒杀一切 提交于 2019-11-28 16:40:02
This command works with HiveQL: insert overwrite directory '/data/home.csv' select * from testtable; But with Spark SQL I'm getting an error with an org.apache.spark.sql.hive.HiveQl stack trace: java.lang.RuntimeException: Unsupported language features in query: insert overwrite directory '/data/home.csv' select * from testtable Please guide me to write export to CSV feature in Spark SQL. You can use below statement to write the contents of dataframe in CSV format df.write.csv("/data/home/csv") If you need to write the whole dataframe into a single CSV file, then use df.coalesce(1).write.csv("