FAQ Database Discussion Community


PHP GET and POST - not working

php,csv
I am a beginner with php and have the following code for getting values from a form and inserting it into a csv file as an array PHP: if(isset($_GET['submitted'])){ $csvData = [$_GET["contract"],$_GET["article"],$_GET["specs"]]; $fp = fopen("order.csv","a"); if($fp) { fputcsv($fp,$csvData); // Write information to the file fclose($fp); // Close the file }...

Is it possible to output to a csv file with multiple sheets?

java,excel,csv
I need to output data to a CSV file from Java, but in that csv file I hope to create multiple sheets so that data can be organized in a better way. After some googling, it seems this is not possible. A CSV file can only receive one-sheet data. Is...

Import csv file and update existing table in Postgres

postgresql,csv,heroku-postgres,csv-import
I have a Postgres database on Heroku. I connect to it using pgadmin. I exported a table data to csv. Edited some of the cells and now I want to replace the same table with the corrected csv. But when I try to import the csv I get this error...

type conversion performance optimizable?

c#,xml,csv,optimization,type-conversion
The following snippet converts xml data to csv data in a data processing application. element is a XElement. I'm currently trying to optimize the performance of the application and was wondering if I could somehow combine the two operations going on below: Ultimately I still want access to the string...

How Do I Transform This CSV / Tabular Data Into A Different Shape?

excel,csv
I have a sparse n-column spreadsheet where the first two columns describe a person and the rest of the (n-2) columns track RSVP and attendance data for various events (each of which take up one column). It looks like this: PersonID, Name, Event29108294, Event01838401, Event10128384 12345, John Smith, Registered -...

Rearranging a csv file

bash,shell,csv,awk,scripting
I have a file with contents similar to the below Boy,Football Boy,Football Boy,Football Boy,Squash Boy,Tennis Boy,Football Girl,Tennis Girl,Squash Girl,Tennis Girl,Tennis Boy,Football How can I use 'awk' or similar to rearrange this to the below: Football Tennis Squash Boy 5 1 1 Girl 0 3 1 I'm not even sure if...

upload CSV file to database on Google app engine using Python

python,database,google-app-engine,csv,upload
I'm a newbie in python and started learning it from about a week. I was looking into couple of tasks one of which was to upload a file (.txt or .jpg) to a bucket on GAE. I was able to solve it by following couple of tutorials online, but i'm...

Renaming the x-axis values in matplotlib

python-2.7,csv,matplotlib,graphing
NOTE: This is all done on a windows 7 x64bit machine running python2.7 and the most recent version of matplotlib. I have a csv file that contains the liquor sales in Iowa from January 2014 to February 2015. If your interest is suddenly piqued, the file can be found at:...

Save imported csv data in vector - R

r,csv
I have found read.csv("file.csv")$V1 that may help to split exported table into columns but my data is organised in a row-by-row fashion, so I would like to record elements to vector sequentially from element[1][1] ->...->element[n][n]. Any thoughts how it could be accomplished in R? Update: Once imported mydata looks like: dat...

Python CSV read file and select columns and write to new CSV file

python,csv
I have a CSV file which has certain columns which I need to extract. One of those columns is a text string from which I need to extract the first and last items. I have a print statement in a for loop which get exactly what I need but cannot...

Import CSV file to Postgre

php,postgresql,csv
I'm writing some PHP code to import a CSV file to a Postgre DB, and I'm getting the error below. Can you help me? Warning: pg_end_copy(): Query failed: ERROR: literal newline found in data HINT: Use "\n" to represent newline. CONTEXT: COPY t_translation, line 2 in C:\xampp\htdocs\importing_csv\importcsv.php on line 21...

Reading CSV File Using Scanner Class Error

java,csv,java.util.scanner,delimiter
I have an original code that came from a Java book example. The program simply reads a text file ("clients.txt"). However, I would like to modify the "clients.txt" into a "clients.csv" and have the program read ".csv" file instead. I have parsed the data with "," as the delimiter according...

How to remove all except the first 3 and last of a specific character with sed

regex,bash,csv,sed
I've looked all over the place but can't find an answer. I've used sed before so I'm familiar with the syntax - however this one has me stumped. I want to remove all except the first 3 instances and the last instance of a specific character. Here is a specific...

Converting list to array with NumPy asarray method

python,csv,python-3.x,numpy
I try get mean from csv line. I get data from csv in string list, further i convert it to array with numpy. Its work perfect when i try plot some graphics. But when i calculate mean i get some errors with my data. If i use NumPy i get:...

How to split a CSV file into multiple files based on column value

bash,csv,awk
I have CSV file which could look like this: name1;1;11880 name2;1;260.483 name3;1;3355.82 name4;1;4179.48 name1;2;10740.4 name2;2;1868.69 name3;2;341.375 name4;2;4783.9 there could more or less rows and I need to split it into multiple .dat files each containing rows with the same value of the second column of this file. (Then I will...

Converting very large files from xml to csv

c#,xml,csv,converter,large-files
Currently I'm using the following code snippet to convert a .txt file with XML data to .CSV format. My question is this, currently this works perfectly with files that are around 100-200 mbs and the conversion time is very low (1-2 minutes max), However I now need this to work...

How can i add two tables in excel csv file?

c#,excel,csv,export
I am creating excel CSV file using the following code its working fine for me generating the first image table.But i want to generate the CSV for the image second.Can anyone please tell me how can i add two tables in single file and how can i insert record where...

Resampling and merging data frame with python

python,csv,pandas,resampling,merging-data
Hi I have created a dictionary of dataFrame with this code import os import pandas import glob path="G:\my_dir\*" dataList={} for files in glob.glob(path): dataList[files]=(read_csv(files,sep=";",index_col='Date')) The different dataframe present in the dictory have different time sample. An example of dataFrame(A) is Date Volume Value 2014-01-04 06:00:02 6062 108000.0 2014-01-04 06:06:05 6062...

Writing a set plus a formatted string to a CSV?

python,csv
I'm trying to write the contents of a set and a formatted string to a CSV file using Python 2. I have a set full of domain names, and I need to write the domain name to the first column, skip one column, then write the word 'Related', and repeat...

Parsing CSV in Python 101

python,parsing,csv
I'm trying to understand/visualise the process of parsing a raw csv data file in Python from dataquest.io's training course. I understand that rows = data.split('\n') splits the long string of csv file into rows based on where the line break is. ie: day1, sunny, \n day2, rain \n becomes day1,...

How to .write() two items, a zero and an iterator in Python?

python,csv,formatting,conditional-statements,writing
I may have a simple formatting question here - I would like to do something like hrOut.write('0',i) in order to add/preface a zero to 'i' which is a timestamp, but I don't know the correct syntax. My code is below. Thank you all. hrIn = open('HrsInput.csv') hrOut = open('HrsOutput.csv', 'wt')...

Replace improper commas in CSV file

regex,r,csv
This may have been asked before, but I couldn't find it. I have a list of CSV files (439 or so) where, in a few of the files, someone also used commas in editorial comments. The result is that I can't put the files into a data frame, since the...

Perl: Using Text::CSV to print AoH

arrays,perl,csv
I have an array of hashes (AoH) which looks like this: $VAR1 = [ { 'Unit' => 'M', 'Size' => '321', 'User' => 'test' } { 'Unit' => 'M' 'Size' => '0.24' 'User' => 'test1' } ... ]; How do I write my AoH to a CSV file with separators,...

File is not being downloaded when requested through Ajax using JQuery

javascript,jquery,ajax,file,csv
I need to download a .CSV file with certain information from a website, so I'm using a link and some Javascript/JQuery to get the table from the servr and create the file. I have this link that is supposed to download the file when clicked: <a class="areaSummaryExport" value="1">...</a> And then...

Convert delimited string to array and group using LINQ in C#

c#,arrays,linq,csv
I have a string that has a delimited format like this: orgname: firstname lastname, firstname lastname; (this can repeat with orgnames and variable number of names for each org) Example: **XXX University**: Martha Zander, Rick Anderson; **Albert School**: Nancy Vanderburg, Eric Towson, George Branson; **Hallowed Halls**: Jane Goodall, Ann Crabtree,...

export mysql query array using fputcsv

php,mysql,arrays,csv,fputcsv
I am trying to export the results of a sql query to CSV using fputcsv however keep getting the error "fputcsv() expects parameter 2 to be array, string given". I followed the answer given here - Query mysql and export data as CSV in PHP - but it throws the...

Reading csv with Python breaks on square bracket

python,csv
I have a csv that I'm trying to read with Python, which has lines that look like the following: 10x org il,"["Modiin, Israel"]","["no current price posted"]","["Modiin: no current size posted"]","{ "Python Bootcamp": {"Price: ","["http://www.10x.org.il/"]","[{ "j": 31.9077, "C": 35.0076 }]" but it breaks on the first square bracket of this: "[{...

Opening csv of specific sequences: NAs come out of nowhere?

r,csv
I feel like this is a relatively straightforward question, and I feel I'm close but I'm not passing edge-case testing. I have a directory of CSVs and instead of reading all of them, I only want some of them. The files are in a format like 001.csv, 002.csv,...,099.csv, 100.csv, 101.csv,...

Sum values from input-csv

powershell,csv
i have a csv sheet like one given below, (some cells can be empty, actual sheet i have is having upto disk 20), ID name disk1 disk2 disk3 001 abc 50 50 50 002 def 100 100 003 xyz 50 I need to input this sheet to powershell script and...

How to process the irregular json file in python to get the serialized values in CSV?

python,json,csv
{\n \"1 & 1 Internet\": {\n \"category\": \"Infrastructure\",\n \"xyz\": 55,\n \"abc\": \"low\"\n },\n \"1 website hosting\": {\n \"category\": \"Infrastructure\",\n \"xyz\": 0,\n \"abc\": \"poor\"\n },\n \"10000ft\": {\n \"category\": \"Collaboration\",\n \"xyz\": 48,\n \"abc\": \"poor\"\n },\n \"1010data\": {\n \"category\": \"Big Data\",\n \"xyz\": 56,\n \"abc\": \"low\"\n },\n \"101domains\": {\n \"category\": \"Infrastructure\",\n \"xyz\": 0,\n \"abc\":...

Accessing csv file placed in hdfs using spark

csv,hadoop,apache-spark,pyspark
I have placed a csv file into the hdfs filesystem using hadoop -put command. I now need to access the csv file using pyspark csv. Its format is something like `plaintext_rdd = sc.textFile('hdfs://x.x.x.x/blah.csv')` I am a newbie to hdfs. How do I find the address to be placed in hdfs://x.x.x.x?...

Populate csv with Scala

python,scala,csv,apache-spark
I have a csv file which is more or less "semi-structured) rowNumber;ColumnA;ColumnB;ColumnC; 1;START; b; c; 2;;;; 4;;;; 6;END;;; 7;START;q;x; 10;;;; 11;END;;; Now I would like to get data of this row --> 1;START; b; c; populated until it finds a 'END' in columnA. Then it should take this row -->...

Python: isolating re.search results

python,regex,csv
So I have this code (probably super inefficient, but that's another story) that is pulling urls from html code of a blog. I have the html in a .csv, which I am putting into python, then running the regex to get the urls. Here is the code: import csv, re...

export tableau to csv including measures

csv,tableau
I have a tableau workbook that was given to me. I open it and I see everything there. I want to export the data to CSV including the measures which are a bunch of sums. Right now the measures are in the right 4 'colummns' but not in the column...

Powershell script for Excel error code

excel,powershell,csv,export-to-csv,powershell-v4.0
I'm trying to convert an Excel .xls file that has several worksheets into a .csv with Powershell 4.0. I know the SaveAs in the for each loop isn't phrased right, and that the error is pointing to line 17 and character 9, I just don't know how to fix it...

Python Datetime into MySQL

python,mysql,csv,datetime
I'm parsing several years worth of daily solar generation CSV files that look like this (with YY-MM-DD.CSV filename format) sep=; Version CSV|Tool SunnyBeam11|Linebreaks CR/LF|Delimiter semicolon|Decimalpoint point|Precision 3|Language en-UK|TZO=0|DST|11/03/2012 ;SN: xyz ;SB blah ;xyz Time;Power HH:mm;kW 00:10;0.000 00:20;0.000 00:30;0.000 00:40;0.000 00:50;0.000 01:00;0.000 01:10;0.000 01:20;0.000 01:30;0.000 01:40;0.000 01:50;0.000 02:00;0.000 02:10;0.000 02:20;0.000 02:30;0.000...

How to match every beginning of new line of text in Regex?

regex,csv
I'm in the process of creating a CSV file out of a text file. Very new to Regex and I need to finish the CSV file. What I need to do is to remove every new line of text and put them in one single line. For example, this data:...

How to pivot array into another array in Ruby

arrays,ruby,csv
I have a multidimensional array like this one : myArray = [["Alaska","Rain","3"],["Alaska","Snow","4"],["Alabama","Snow","2"],["Alabama","Hail","1"]] I would like to end up with CSV output like this. State,Snow,Rain,Hail Alaska,4,3,nil Alabama,2,nil,1 I know that to get this outputted to CSV the way I want it I have to have output array like this: outputArray =[["State","Snow","Rain","Hail"],["Alaska",4,3,nil],["Alabama",2,nil,1]]...

How to append datatable to existing records in CSV file

powershell,csv,datatable
I have CSV file MyFile.csv. It contains following data: RollNumber Name 1 Amol 2 Ravi Now I am fetching few records from SQL Server as follows: RollNumber Name 3 Viku 4 Vaibhav I am not able to find a way to append these new records to existing CSV file. I...

How to find length of all .csv files in directory?

vba,file,csv
I have multiple .csv files that I need to find the length of in my directory. (The number of rows that have data in them.) I'm running the following code from a .xlsx file in the same directory. (I intend to copy data from the .csv files to the .xlsx...

How to collect data from text file to dict in Python?

python,python-2.7,csv,dictionary
I have the following table generated in a text file,"fasta.txt" A C G T 0 0.195965417867 0.322766570605 0.35446685879 0.126801152738 A1 0.25 0.1875 0.3125 0.25 C1 0.25 0.475 0.225 0.05 G1 0.135135135135 0.243243243243 0.405405405405 0.216216216216 T1 0.142857142857 0.285714285714 0.285714285714 0.285714285714 A2 0.125 0.208333333333 0.625 0.0416666666667 C2 0.0833333333333 0.416666666667 0.305555555556 0.194444444444 G2...

CSV File header part is coming parsing by LINQ

c#,linq,csv
the below way i am parsing csv file by LINQ but i found header part is coming when i inspect user class data. what is wrong there in code. var csvlines = File.ReadAllLines(filename); // IEnumerable<string> var csvLinesData = csvlines.Select(l => l.Split(',').Skip(1).ToArray()); // IEnumerable<string[]> int flag = 0; var users =...

MySQL is adding characters to my data

mysql,csv,load
I have a Table in MySQL and I am adding data to it from a csv file My code is: LOAD DATA LOCAL INFILE 'C:/myaddress/file.csv' INTO TABLE db.mytable FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\r\n' (`Currency`,`field2`,`field3`) This loads fine except for the first row I add....

Naming pandas columns from arbitrary row data

python,csv,pandas
I have a python script where I have read in a csv file using pandas: colnames = ['col1','col2','col3','col4','col5','col6','col7','col8','col9','col10'] csv_input = pd.read_csv(ifile, names=colnames) The CSV file is filled with lots of uneeded junk, but the column names I want to use are defined by a row with DataName in col1. csv_names...

IndexError obstructing code from working with larger csv file

python,csv,indexing,pandas
I have data that sorts a csv by using groupby and then plots the information. I used a small sample of information to create the code. It ran smoothly and so then I tried running it with the huge file of data. I am pretty new at Python and this...

Compare 2 seperate csv files and write difference to a new csv file - Python 2.7

python,python-2.7,csv,compare
I am trying to compare two csv files in python and save the difference to a third csv file in python 2.7. import csv f1 = open ("olddata/file1.csv") oldFile1 = csv.reader(f1) oldList1 = [] for row in oldFile1: oldList1.append(row) f2 = open ("newdata/file2.csv") oldFile2 = csv.reader(f2) oldList2 = [] for...

Specific rows from CSV as dictionary and logic when keys are the same - Python

python,csv,dictionary
abc11 bvc ex 123 456 somestuffhere abc11 bvc ex 456 476 somestuffhere abc12 bvc ex 173 426 somestuffhere abc12 bvc ex 426 496 somestuffhere abc13 bvc ex 143 796 somestuffhere abc13 bvc ex 743 896 somestuffhere I am trying to put the above CSV file as a dictionary, {'abc11':['123','476'],'abc12':['173','496'],'abc13':['143','896']}. I...

How to stop foreach loop from printing duplicate data?

php,csv,foreach
I am trying to generate unique CSV files from the csv data that I have using the following loop. $k =1; foreach ($csv_tbl as $_csv) { $filename = "Agent_" . $k . ".csv"; $file_path = "agents/$filename"; file_put_contents($file_path, $_csv); if (file_exists($_csv)) { header('Content-Description: File Transfer'); header('Content-type: text/csv'); header('Content-Disposition: attachment; filename=' ....

Ajax call and function.apply infinite loop

javascript,jquery,ajax,csv
I'm trying to print a .CSV in a web app I'm building for that purpose I have a link, something simple: <a class="areaSummaryExport" value="1">...</a> Then with Javascript and JQuery I do: $('.areaSummaryExport').on('click', function(){ exportAreaSummary($(this).attr('value'), $(this)); }); To export the .CSV with JQuery I need a <table> so I use ajax...

writing csv output python

python,csv
I need to take a csv file that looks like this... Name,Price1,Price2,Date1,Date2 ABC,1000,7500,5/1,6/1 DEF,3000,500,5/1,7/1 GHI,5000,3500,6/1,8/1 and write it out to another csv file to make it look like this... Name,May,June,July,August ABC,7500,1000, , DEF,500, ,3000 GHI, ,3500, ,5000 the spaces are suppose to be blank because nothing goes there and this...

Entity framework to CSV float values

c#,entity-framework,csv
I'm trying to write an object to csv, the thing is that my objects have float valure for exemple (14,9) i want to change them to (14.9) so it won't cause any problem with the csv format string csv = ""; using (var ctx = new NBAEntities2()) { var studentList...

export a list as a csv file in python and getting UnicodeEncodeError

python,csv
I want to get a csv file from my list. This is my list: temp = ['سلام' , 'چطوری' ] Members of list are in Persian language. I tried to get csv file by this code: import csv with open("output.csv", "wb") as f: writer = csv.writer(f) writer.writerows(temp) but terminal gives...

BASH - conditional sum of columns and rows in csv file

linux,bash,csv,awk
i have CSV file with some database benchmark results here is the example: Date;dbms;type;description;W;D;S;results;time;id Mon Jun 15 14:22:20 CEST 2015;sqlite;on-disk;text;2;1;1;570;265;50 Mon Jun 15 14:22:20 CEST 2015;sqlite;on-disk;text;2;1;1;420;215;50 Mon Jun 15 14:22:20 CEST 2015;sqlite;on-disk;text;2;1;1;500;365;50 Mon Jun 15 14:22:20 CEST 2015;sqlite;on-disk;text;2;1;1;530;255;50 Mon Jun 15 14:22:20 CEST 2015;hsql;on-disk;text;2;1;1;870;265;99 Mon Jun 15 14:22:20 CEST 2015;hsql;on-disk;text;2;1;1;620;215;99...

Python CSV reader/writer handling quotes: How can I wrap row fields in quotes? (Getting triple quotes as output)

python,csv
I have a problem with the csv reader and writer in python. Whenever I try to take one CSV file and par down the number of columns from roughly 37 to 6, this is the kind of output I am getting. Example of one row: 0,"JOHNSON, JOHN J.",JOHN J. JOHNSON,TECH879,INSPECTION...

Replace numbers with Boolean in r

r,csv,replace,weka
I want to use weka to predict future instances. I have a csv file and a small portion of it is as following: I used r to read the file but I am not sure how to substitute the zeros with "No error" and anything besides zero to "Error". I...

Generic csv parser in java

java,parsing,csv
I have a csv file with headers in order fname,mname,lname and a csv parser to parse this. I am reading the file line by line and splitting by delimitter (",") and according to index i'll get the values 0=fname, 1=mname, 2=lname. Now again if a csv comes with headers in...

Copying CSV File when integer exceeds maximum

python,python-2.7,csv,typeerror
If this input exists in a specific row, for example DD in row WORD4 (row 3), the program will then ask them to enter an integer and if this is over a certain number it will write it including the line. Something like so: a0,a1,a2,a3,a4 JA,BV,PA,DD,6 The error received I...

Group instances based on NA values in r

r,file,csv,instance,na
I am reading a csv file and unfortunately my dataframe has many missing values. A small snip is as following: df <- data.frame(Size= c(800, 850, 1100, 1200, 1000), Value= c(900, NA, 1300, 1100, NA), Location= c(NA, 'midcity', 'uptown', NA, 'Lakeview'), Num1 = c(2, NA, 3, 2, NA), Num2 = c(2,3,3,1,2),...

Can't read first row of CSV file

csv,vbscript,imacros
I can't figure out why my script is not reading and storing the first row of the CSV file. It is starting with the second row for some reason. I have the following code (reading from a 2 column CSV file): Set rs = CreateObject("ADOR.Recordset") 'this just gets the folder...

Creating Textfiles within executable JAR

java,csv,executable-jar
I have created a java application which runs fine, and I have exported it as a jar. The jar export also runs properly, except for one issue: when I run it e.g. on the desktop, it creates csv files on the desktop. Is there a way to create csv files...

Python - Remove Braces and Commas from a Tuple CSV File

python,csv
I'm printing out to a csv file like this: bdictionary = ## bdictionary is a big list of tuples w = csv.writer(open("testnucsv.csv", "w")) for sent in bdictionary: w.writerow(sent) And it prints out perfectly fine and looks like this: (u'My', u'D') (u'dog', u'N')............... (u'The', u'D') ............................ How can I print it...

Hive external table not reading entirety of string from CSV source

csv,hadoop,hive,hiveql
Relatively new to the Hadoop world so apologies if this is a no-brainer but I haven't found anything on this on SO or elsewhere. In short, I have an external table created in Hive that reads data from a folder of CSV files in HDFS. The issue is that while...

Create an external Hive table from an existing external table

csv,hadoop,hive
I have a set of CSV files in a HDFS path and I created an external Hive table, let's say table_A, from these files. Since some of the entries are redundant, I tried creating another Hive table based on table_A, say table_B, which has distinct records. I was able to...

Python: Using panda to import csv. Trying to plot a column but gives me an error saying “no numerical data to plot”

python,csv,pandas,plot
I'm trying to read following csv-file with panda and plot a column of it: data type,approved mining area,mined area,coal content,earth rate,coal rate,waste ratio unit,ha,ha,Mt,Mm3/a,Mt/a, Garzweiler,11400,3096,1246,140,37.5,4.4 Hambach,8500,4224,1500,275,40,5.2 Inden,4500,1655,358,87.5,22.5,3.6 which gives me the following (only a part so it fits here): data type approved mining area mined area coal content earth rate...

Adding time/duration from CSV file

python,python-2.7,csv,datetime
I am trying to add time/duration values from a CSV file that I have but I have failed so far. Here's the sample csv that I'm trying to add up. Is getting this output possible? Output: I have been trying to add up the datetime but I always fail: finput...

Convert strings of data to “Data” objects in R [duplicate]

r,date,csv
This question already has an answer here: as.Date with dates in format m/d/y in R 2 answers My problem is that the as.Date function does not convert the values in a "date" column of a data frame into Date objects. I have a data.frame nmmaps. Here is a short...

Creating unique Mongoose objects from CSV

javascript,node.js,mongodb,csv,mongoose
Let's say that I have a CSV containing information that needs to be parsed into different Mongoose objects. I need to either find or create a "User" based on a some information in the CSV file. If I run this, however, it will create a new User each time, since...

read specific line in csv file , python

python,csv,reader
In an CSV file with python we can read all the file line by line or row by row , I want to read specific line (line number 24 example ) without reading all the file and all the lines.

Compare 2 csv files and output different rows to a 3rd CSV file using Python 2.7

python,python-2.7,csv,compare
I am trying to compare two csv files and find the rows that are different using python 2.7. The rows are considered different when all columns are not the same. The files will be the same format with all the same columns and will be in this format. oldfile.csv ID...

Addition of two dates on python 3

python,csv,datetime,python-3.x
I try adding date and hours from csv file in one datetime variable. I read questions about adding some timedelta and official doc https://docs.python.org/3/library/datetime.html#timedelta-objects, but don't understend how it works. My csv row looks like - ['2005.02.28', '17:38', '1.32690', '1.32720', '1.32680', '1.32720', '5'].I convert row[0] = 2005.02.28 to date and...

Export Moodle report in csv file

php,database,csv,report,moodle
Does anyone know any Moodle built in feature to export custom report into a csv file? I've tried to find in documentation but there is nothing. There's this old book which also have no practical information on exporting report into a csv file. I've tried to dig into the source...

Adding Hyphen in row data in python

python,csv
In my csv file, i have a col with value like A12001 A22001 A32001 I need to make it look like A1-2001 A2-2001 A3-2001 I am new to python. Any help will be appreciated. Thanks...

Run 3 variables at once in a python for loop.

python,loops,variables,csv,for-loop
For loop with multiple variables in python 2.7. Hello, I am not certain how to go about this, I have a function that goes to a site and downloads a .csv file. It saves the .csv file in a particular format: name_uniqueID_dataType.csv. here is the code import requests name =...

How to make xml to csv parsing/conversion faster?

c#,xml,parsing,csv
I'm currently using the snippet below to convert xml data(not well formed) to .CSV format after doing some processing in between. It only converts those elements in the xml data that contain a integer from the list testList (List<int> testList). It only converts and writes to the file once that...

How to rearrange CSV / JSON keys columns? (Javascript)

javascript,json,csv,papaparse
I am converting a JSON object array to CSV using Papa Parse JavaScript Library. Is there a way to have the CSV columns arranged in a certain way. For e.g; I get the column as: OrderStatus, canOp, OpDesc, ID, OrderNumber, FinishTime, UOM, StartTime but would like to be arranged as:...

Whats the simplest way when writing & reading a 2D-boolean-Array to a CSV File?

java,arrays,parsing,csv
I'd like to write a 2-Dimensional boolean-Array to a CSV file. Im using Apache Commons' CSVParser. The Problem is that I couldnt find a built-in way to turn the Array into something that can be written into an CSV-File and then later converted back. So is there a way apart...

Exporting Data from Cassandra to CSV file

apache,csv,cassandra,export,export-to-csv
Table Name : Product uid | productcount | term | timestamp 304ad5ac-4b6d-4025-b4ea-8b7991a3fe72 | 26 | dress | 1433110980000 6097e226-35b5-4f71-b158-a1fe39a430c1 | 0 | #751104 | 1433861040000 Command : COPY product (uid, productcount, term, timestamp) TO 'temp.csv'; Error: Improper COPY command. Am I missing something? ...

Python csv writer: write a string in front of an array, all in individual columns

python,csv
Given the following data: names = ['a','b','c','d'] matrix = [array[1,2,3,4],array[5,6,7,8],array[9,10,11,12],array[13,14,15,16]] I am trying to print one name in front of each array on a csv file, like so: Desired Output: 'a',1,2,3,4 'b',5,6,7,8 etc... So far, I have this code: with open('test.csv', 'a') as csvfile: writer = csv.writer(csvfile, dialect='excel') counter =...

Saying there are 0 arguments when I have 2? Trying to open a CSV file to write into

ruby,file,csv,dir
I'm trying to read from a CSV file and codify people into groups using an equation. I append the name of their group they fall into to the end of the array that their row creates. Then I write it to a new file so I don't overwrite the original...

Read two csv files and concatenate their two columns into new file with php [closed]

php,csv
I want to concatenate two CSV files: url.csv : www.text.com/test.html www.text.com/test1.html www.text.com/test2.html color.csv : Red Black Pink result should like : www.text.com/test.html?color=Red www.text.com/test1.html?color=Red www.text.com/test2.html?color=Red www.text.com/test.html?color=Black www.text.com/test1.html?color=Black www.text.com/test2.html?color=Black my final code : $url_csv = "cache_build_urls_file.csv"; $url_csv_resource = fopen($url_csv,"r"); $color_csv = "colors_file.csv"; $color_csv_resource =...

Mass Export of BLOB data to CSV

oracle,csv,export
I am working with an older Oracle database, I don't know which version of oracle, sorry, and I need to do a mass export of 200,000+ files worth of HTML data stored in BLOBs. I have downloaded and used both Toad and SQLDeveloper (Oracle's own DB GUI tool) and at...

display.im6: no decode delegate for this image format `/tmp/magick-KFcbfWUi'

linux,r,bash,shell,csv
I'm using Rio and I have a sample.csv which looks as following hour,count 0300,0 0300,0 0300,1 0300,1 0300,2 0301,1 0301,2 0301,2 0301,3 I run following command: $ < sample.csv Rio -ge 'g + geom_bar(df, aes(hour, count))' | display and I get display.im6: no decode delegate for this image format `/tmp/magick-Gvr3kRZh'...

How to loop through XmlDocument and return a csv?

c#,xml,csv
I am trying to loop through an XmlDocument object and return a reasonable csv. I am able to traverse all nodes using recursion private StringBuilder findAllnodes(XmlNode node, StringBuilder buf) { foreach (XmlNode n in node.ChildNodes) { findAllnodes(n, buf); if (n.NodeType == XmlNodeType.Text) { buf.AppendFormat("{0}",n.InnerText.Trim()); } else { buf.AppendFormat("{0}, {1}", n.Name,...

Print lines in a csv file if the values are consecutive

python,csv
I have the following csv file: Value1,Value2,Value3,Value4 11,12,27,28 5,6,101,102 111,112,55,56 1,7,33,34 3,4,55,57 I want to print lines if Value1 & Value2 are consecutive AND Value3 & Value4 are consecutive. The desired answer would be: 11,12,27,28 5,6,101,102 111,112,55,56 I tried something like this but it didn't work f = open('test.csv', 'rU')...

Panda's Write CSV - Append vs. Write

python,csv,pandas
I would like to use pd.write_csv to write "filename" (with headers) if "filename" doesn't exist, otherwise to append to "filename" if it exists. If I simply use command: df.to_csv('filename.csv',mode = 'a',header ='column_names') The write or append succeeds, but it seems like the header is written every time an append takes...

CSV file to hash

ruby,csv
I want to take a simple 2-column CSV file and turn it to a Hash of initials as keys, full name as values. How would you do this? csv_text = File.read('composer_initials.csv') csv = CSV.parse(csv_text, :headers => true) I've tried: csv.to_a.map {|row| ro.to_hash} csv.map {|row| row.to_hash} SOLUTION: This ended up doing...

What would be the fastest way to insert this data

mysql,sql,database,performance,csv
Okay, so I have a MySQL table called entries which contains the columns name VARCHAR(255) NOT NULL and address VARCHAR(255) The table has about a million sets of data. For every set of data, name has a value e.g. "john" whilst address is NULL. For example: +------+---------+ | name |...

gnuplot - How can I count the number of entries in a csv file column?

csv,plot,gnuplot,function-fitting
I have a gnuplot code which includes a function fitting routine. This routine is slow when a large number of data points must be fitted. The number of data points in my input file is variable depending on the parameters of some simulations I am running. I wish to fit...

Read CSV and plot colored line graph

python,csv,matplotlib,graph,plot
I am trying to plot a graph with colored markers before and after threshold value. If I am using for loop for reading the parsing the input file with time H:M I can plot and color only two points. But for all the points I cannot plot. Input akdj 12:00...

Read a csv with numpy array using pandas

python,csv,numpy,pandas
I have a csv file with 3 columns emotion, pixels, Usage consisting of 35000 rows e.g. 0,70 23 45 178 455,Training. I used pandas.read_csv to read the csv file as pd.read_csv(filename, dtype={'emotion':np.int32, 'pixels':np.int32, 'Usage':str}). When I try the above, it says ValueError: invalid literal for long() with base 10: '70...

How to find the difference between two lists of dictionaries checking the key-value pair

python,list,csv,dictionary
I've already searched for a solution to my problem but with no success. Part of the solution for my problem is here, but this does not solve it all. I have two lists of dictionaries like this - each dictionary is written to a csv file but I read the...

Multiple pandas.dataframe to one csv file

python,csv,pandas
I have multiple pandas dataframes, and hope to write them as one CSV file. What is the most straightforward way? For example, from following four dataframes, how can I create below CSV? Note The dataframes all have the same dimensions....

csv.writerows() puts newline after each row

python,csv,python-3.x
This is an example from the O'Reilly Cookbook (truncated dataset) headers = ['Symbol','Price','Date','Time','Change','Volume'] rows = [{'Symbol': 'AA', 'Volume': 181800, 'Change': -0.18, 'Time': '9:36am', 'Date': '6/11/2007', 'Price': 39.48}, {'Symbol': 'AIG', 'Volume': 195500, 'Change': -0.15, 'Time': '9:36am', 'Date': '6/11/2007', 'Price': 71.38} ] with open('stocks2.csv','w') as f: f_csv = csv.DictWriter(f, headers) f_csv.writeheader() f_csv.writerows(rows)...

How to write a csv with quotes?

python,csv
I'm working with python, and also i'm working on a csv parse script, but i cannot write as CSV the new file with quotes as the input file, i access to the file in this way: def read_file(self): with open(self.file) as f: parse_data=[row for row in csv.reader(f, delimiter=',',quotechar=('\"'), skipinitialspace=True)] parse_data=self.organize_file(parse_data)...

Extract Values from CSV file to then multiply with values from other CSV? Python

python,csv
I'm very new to programing and using python especially. I have a CSV file that is 20 by x, and has a variety of probability values. it will look somethign like this: A B C D E 1 2 3 4 5 6 7 8 9 10 11 12 13...

How can I use a variable to get an Input$ in Shiny?

r,variables,csv,shiny
I am new to R and I am creating a shiny application to read a csv and filter data. I am reading the csv file, then creating dropdowns with a loop using the column names and the unique values: output$dropdowns <- renderUI({ if (is.null(x())) { return(NULL) } lapply(1:ncol(x()), function(i) {...

create multidimensional associative array from CSV in PHP

php,csv,multidimensional-array,associative-array
I'm trying to create a multidimensional array in PHP where the inner arrays are associative for the following example CSV string $csv: # Results from 2015-06-16 to 2015-06-16. date,time,label,artist,composer,album,title,duration 2015-06-16,12:00 AM,Island,U2,"Clayton- Adam,The Edge,Bono,Mullen- Larry- Jr",Songs Of Innocence,SONG FOR SOMEONE,03:46 2015-06-16,12:04 AM,Lowden Proud,"Fearing & White, Andy White, Stephen Fearing","White- Andy,Fearing- Stephen",Tea...

Sorting entire csv by frequency of occurence in one column

python,sorting,csv,pandas,frequency
I have a large csv file, which is a log of caller data. A short snippet of my file: CompanyName High Priority QualityIssue Customer1 Yes User Customer1 Yes User Customer2 No User Customer3 No Equipment Customer1 No Neither Customer3 No User Customer3 Yes User Customer3 Yes Equipment Customer4 No User...

Parse text from a .txt file using csv module

python,python-2.7,parsing,csv
I have an email that comes in everyday and the format of the email is always the same except some of the data is different. I wrote a VBA Macro that exports the email to a text file. Now that it is a text file I want to parse the...

Adding data from a csv file to a List using a loop

c#,list,csv
I am new to developing and this is my first question, so please excuse any misunderstanding in my explanation. I am trying to import the data from a csv file into a list of objects I defined. My file has 2 columns and 5 rows: 1 for the date and...