csv

Split a CSV field into different rows in SQL

亡梦爱人 提交于 2021-02-17 05:34:06
问题 A colleague of mines encountered this problem while working on a COBOL program and eventually solved it at the application level. Still I am curious if it is possible to solve it on the data access level, with SQL. This is somehow related to this other question, but I'd like to use only ANSI SQL. I'm looking for a single SQL select query that acts on a VARCHAR field that contains variable length CSV rows. The purpose of the query is to split every CSV field in its own result set row. Here is

Get LastAccessTime for each subfolders in a csv folder list

假如想象 提交于 2021-02-17 02:47:51
问题 I have a csv ($HomeDir) file like this: Users,Comments,HomeDir user1,account1,c:\folder1 user2,account2,c:\folder2 user3,account3,c:\folder3 I get succesfully LastAccessTime for each subfolder in 'HomeDir' column with this code: $csv = Import-Csv $HomeDir foreach ($folder in $csv.HomeDir) { Get-ChildItem $folder -ErrorAction SilentlyContinue | ? {$_.PSIsContainer -eq "True"} | Select-Object FullName, @{Name='LastAccessTime'; Expression={$_.LastAccessTime.ToString('yyyyMMdd')}} | Sort-Object

Pandas read csv where one header is missing

主宰稳场 提交于 2021-02-17 02:44:26
问题 I am trying to read a csv file with Pandas but the first column contains a first name and a last name seperated by a comma. This causes Pandas to think that there are 5 columns instead of 4 so the last column now has no header making it unable to be selected. The file looks like this: CustomerName,ClientID,EmailDate,EmailAddress FNAME1,LNAME1,100,2019-01-13 00:00:00.000,FNAME1@HOTMAIL.COM FNAME2,LNAME2,100,2019-01-13 00:00:00.000,FNAME2@GMAIL.COM FNAME3,LNAME3,100,2019-01-13 00:00:00.000

Why is fputcsv producing duplicate columns?

送分小仙女□ 提交于 2021-02-16 19:06:26
问题 I am adding a download button to a WordPress site that will query our database, and offer up the result as a CSV. Everything works, except the CSV produced has a duplicate column for each column it returns. We have checked the SQL query and it does not have duplicates. Here's how we are generating the CSV: $rows = //Call to SQL query function $fp = fopen('php://output', 'w'); fputcsv($fp, array_keys($rows)); foreach ($rows as $row) { fputcsv($fp, $row); } $filename = "EventResults.csv";

Why is fputcsv producing duplicate columns?

不羁岁月 提交于 2021-02-16 19:00:46
问题 I am adding a download button to a WordPress site that will query our database, and offer up the result as a CSV. Everything works, except the CSV produced has a duplicate column for each column it returns. We have checked the SQL query and it does not have duplicates. Here's how we are generating the CSV: $rows = //Call to SQL query function $fp = fopen('php://output', 'w'); fputcsv($fp, array_keys($rows)); foreach ($rows as $row) { fputcsv($fp, $row); } $filename = "EventResults.csv";

Use fputcsv() to insert a row at the top of a csv file?

99封情书 提交于 2021-02-16 17:05:39
问题 Pretty simple question. I know how to use fputcsv() to insert a row into a csv but it inserts it at the bottom. Is there a way to use it to insert something at the top of the csv? I need to add a header to an existing csv file. Any help on this would be great. Thanks! 回答1: fputcsv() inserts data at the file pointer, so you can rewind() the pointer to the beginning of the file. rewind($handle); fputcsv($handle, $fields); Alternately, you can simply open the file with the pointer at the

Pass regex to delimiter field in python's csv module or numpy's genfromtxt / loadtxt?

≡放荡痞女 提交于 2021-02-16 16:59:08
问题 I have tabulated data with some strange delimination (i.e. groups of values separated by commas, seperated from other values by tabs): A,345,567 56 67 test Is there a clean and clever way of handling multiple delimiters in any of the following: csv module, numpy.genfromtxt, or numpy.loadtxt? I have found methods such as this, but I'm hoping there is a better solution out there. Ideally I'd like to use a genfromtxt and a regex for the delimiter. 回答1: I’m afraid the answer is no in the three

Combine columns from several CSV files into a single file

 ̄綄美尐妖づ 提交于 2021-02-15 11:34:06
问题 I have a bunch of CSV files (only two in the example below). Each CSV file has 6 columns. I want to go into each CSV file, copy the first two columns and add them as new columns to an existing CSV file. Thus far I have: import csv f = open('combined.csv') data = [item for item in csv.reader(f)] f.close() for x in range(1,3): #example has 2 csv files, this will be automated n=0 while n<2: f=open(str(x)+".csv") new_column=[item[n] for item in csv.reader(f)] f.close() #print d new_data = [] for

Display CSV file in HTML

爷,独闯天下 提交于 2021-02-15 11:09:32
问题 I'm trying to import a local CSV file with headings into a local HTML file, which will then display as a table in a browser. I haven't been learning HTMLand JavaScript for long, so I don't know a lot about importing and converting. What I need is some advice or possibly a basic script describing the sort of function I need. Explanations and advice are all welcomed! This is an example of the csv file: heading1,heading2,heading3,heading4,heading5 value1_1,value1_2,value1_3,value1_4,value1_5

Display CSV file in HTML

橙三吉。 提交于 2021-02-15 11:09:08
问题 I'm trying to import a local CSV file with headings into a local HTML file, which will then display as a table in a browser. I haven't been learning HTMLand JavaScript for long, so I don't know a lot about importing and converting. What I need is some advice or possibly a basic script describing the sort of function I need. Explanations and advice are all welcomed! This is an example of the csv file: heading1,heading2,heading3,heading4,heading5 value1_1,value1_2,value1_3,value1_4,value1_5