export-to-csv

PHP export from MySQL into CSV

点点圈 提交于 2019-12-02 03:10:54
I need to export data from MySQL to CSV but from specific ID. Table contains ID, ParentID and Name and here is code which exports all records: <?php $servername = "localhost"; $username = "root"; $password = ""; $dbname = "databasename"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $index = array(); $num = 0; $sql = "SELECT NAME, ID, PARENTID from tablename"; $result = $conn->query($sql); while($row = $result->fetch_array(MYSQLI_ASSOC)){ $rows[] = $row;

need help to export table from sql server 2008 to text file

别等时光非礼了梦想. 提交于 2019-12-02 02:12:36
问题 I am trying to export a table present in ms sql server 2008 to a text file on my system. I am writing the following command in sql server query window SELECT * FROM [AdventureWorks].[Person].[AddressType] INTO OUTFILE 'C:/filename.csv' FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n'; Now whenever I write this command the sql help gives me error that incorrect syntax near 'INTO' then I tried interchanging from and into keywords as follows SELECT * INTO OUTFILE 'C:/filename.csv' FIELDS

Python 3 - Read from & Write values to a .csv

爱⌒轻易说出口 提交于 2019-12-02 01:27:46
I am reading a .csv file, want to extract certain values from it and write these to a new result.csv (B) file. I tried doing this with the code (A), which is only partially working. In the definition i put all the variables from which i want to eventually extract the matching values out of the .csv file i am reading. (except for "record_id" and "abbreviation", because i will fill these manually) Now by running code (A), it generates the following output in the result.csv: Current output record_id abbreviation patient_id step_count distance ambulation_time velocity cadence normalized_velocity

need help to export table from sql server 2008 to text file

五迷三道 提交于 2019-12-02 00:52:45
I am trying to export a table present in ms sql server 2008 to a text file on my system. I am writing the following command in sql server query window SELECT * FROM [AdventureWorks].[Person].[AddressType] INTO OUTFILE 'C:/filename.csv' FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n'; Now whenever I write this command the sql help gives me error that incorrect syntax near 'INTO' then I tried interchanging from and into keywords as follows SELECT * INTO OUTFILE 'C:/filename.csv' FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n' FROM [AdventureWorks].[Person].[AddressType] ; Now it gives me

Postgresql: CSV export with escaped linebreaks

我的未来我决定 提交于 2019-12-01 19:56:35
问题 I exported some data from a postgresql database using (all) the instruction(s) posted here: Save PL/pgSQL output from PostgreSQL to a CSV file But some exported fields contains newlines (linebreaks), so I got a CSV file like: header1;header2;header3 foobar;some value;other value just another value;f*** value;value with newline nextvalue;nextvalue2;nextvalue3 How can I escape (or ignore) theese newline character(s)? 回答1: Line breaks are supported in CSV if the fields that contain them are

Attach csv to email xcode

大城市里の小女人 提交于 2019-12-01 14:42:26
I got a working csv attachment to an email view. The problem is, that when I open the csv on the iPhone it displays the file really nice into separate columns. But if I open it in excel it's all in one field. I need two columns how can I do that? Tried to separate fields with commas but that didn't work (obviously). The following lines are the ones that must be incorrect somehow, this is where I build my string to write to file [csv appendFormat:@"\n\"Total # of tables: %@\",Total # of objects: %d, \n \n", filteredTables,filteredTableRows] [csv appendFormat:@"\n\"%@\",%@,", key, value]; And

How do I delete certain column from .csv file

核能气质少年 提交于 2019-12-01 14:21:08
I am downloading the list of data but some i would like to ignore some columns, is there any way i can remove them, this is how my database look: ID Name Sname MobileUsage NoBrought 1 test test 12mb 1 2 test1 test1 23mb 8 3 test2 test2 20mb 2 This is what i am getting when i download a .csv file ID Name Sname MobileUsage NoBrought 1 test 12mb 2 test1 23mb 3 test2 20mb Is there any way i can delete Sname and NoBrought as i am not using, my output should be ID Name MobileUsage 1 test 12mb 2 test1 23mb 3 test2 20mb This is what i have done, i assume this program have to look for column heading e

How to export google sheet as CSV by selected columns

会有一股神秘感。 提交于 2019-12-01 13:36:32
I have a Google sheet want to export as CSV file. But there are 2 columns in the sheet I don't want to export. For example, in the picture column , I don't want to export column "N" and "P" Here are the Apps Script code I wrote for export function menu() { var ui = SpreadsheetApp.getUi(); var menu = ui.createMenu('Menu'); var item = menu.addItem('PICC', 'picc'); var item2 = menu.addItem('Export to CSV', 'csv'); item.addToUi(); item2.addToUi() }; function onOpen() { var ss = SpreadsheetApp.getActiveSpreadsheet(); var csvMenuEntries = [{name: "Download Primary Time File", functionName:

Convert Json to CSV using Python

拈花ヽ惹草 提交于 2019-12-01 13:32:15
Below, is the json structure I am pulling from my online weather station. I am also including a json_to_csv python script that is supposed to convert json data to csv output, but only returns a "Key" error. I want to pull data from "current_observation": only. { "response": { "features": { "conditions": 1 } } , "current_observation": { "display_location": { "latitude":"40.466442", "longitude":"-85.362709", "elevation":"280.4" }, "observation_time_rfc822":"Fri, 26 Jan 2018 09:40:16 -0500", "local_time_rfc822":"Sun, 28 Jan 2018 11:22:47 -0500", "local_epoch":"1517156567", "local_tz_short":"EST",

Save all data frames in list to separate .csv files

一个人想着一个人 提交于 2019-12-01 13:29:12
I have a list of data frames that I want to save to independent .csv files. Currently I have a new line for each data frame: write.csv(lst$df1, "C:/Users/.../df1") write.csv(lst$df2, "C:/Users/.../df2") ad nauseam Obviously this isn't ideal: a change in the names would mean going through every case and updating it. I considered using something like lapply(lst, f(x) write.csv(x, "C:/Users/.../x") but that clearly won't work. How do I save each data frame in the list as a separate .csv file? You can do this: N <- names(lst) for (i in seq_along(N)) write.csv(lst[[i]], file=paste0("C:/Users/.../")