Questions tagged [csv]

A comma-separated values file (CSV) stores tabular data in plain-text form.

Filter by
Sorted by
Tagged with
0
votes
1answer
154 views

Create a CSV file from a TXT file

How do I create a CSV file from a TXT file as per the following example? Thanks. TXT file: This is line number one This is line number two with extra words This is line number three with even more ...
6
votes
1answer
748 views

Trying to create a CSV file from a text file in Ubuntu

I have a text file that contains passwords and their respective hashes that is formatted as such: 'plaintext password' 'SHA256 hash' 'SHA3-512 hash' This format continues for several more passwords. ...
0
votes
1answer
37 views

How do I use a shell script to keep only the last populated value for each month in a CSV?

I have a csv file which gets updated by a cron daily and looks something like this: Date,Value 01/11/2019,123 02/11/2019,456 03/11/2019,789 ... 31/01/2020,123 01/02/2020,456 02/02/2020,789 03/02/2020,...
2
votes
4answers
177 views

Selecting rows from csv for a particular day in bash script

I have a CSV file called test.csv containing these values : A,table,20191229 16:41:58 B,table2,20191222 16:41:58 C,table3,20191223 16:40:58 D,table4,20191228 16:41:58 E,table5,20191227 16:41:...
1
vote
1answer
63 views

How to add new columns to CSVs with the same text in all lines

This a sample of my input file: 22/12/1999,conductivity,42,uS/cm 06/01/2000,conductivity,22,uS/cm 26/01/2000,conductivity,26,uS/cm 09/02/2000,conductivity,32,uS/cm 23/02/2000,conductivity,33,uS/cm I ...
3
votes
1answer
578 views

How to find the delimiter used in a txt file and convert it to comma separated csv?

I have a txt file that has either tab or space delimiter. I need to convert it to csv. How do you suggest to do so using command line? $ perl -F"//" -nlae 'for (@F) {$a{$_}++};for (keys %a){print $_ ...
1
vote
0answers
63 views

Remove last character of a text file

How may I remove the last character of a text file in the shell without an unwanted final nextline? Can you believe I tried more than 3 hours... Actually, only this works : printf '%s\n' '$' 's/.$//...
2
votes
1answer
49 views

How to copy files containing a specific phrase to another directory?

I have a huge directory with log-files and want to move files WITH a specific "phrase" in it. i.e. log1.csv ------ containing word "xzy" log2.csv ------ containing word "abc" log3.csv ------ ...
0
votes
0answers
98 views

Replace string with another string in bash script?

I have a .csv sheet with 3 columns and 'n' number of rows. Column1: It defines the name of the Rule. Column2: This is the schema line present in all the test files. Column3: This is the line which ...
0
votes
1answer
47 views

How to rename the exisitng cell names based on number of their occurnaces in a particular column?

I have a column in my excel as below: REF --------- BV1013_1 BV1013_1 BV1013_2 BV1013_2 BV1026 BV1040 BV1040 BV1041 BV1041 BV1042 BV1042 Desired OUTPUT: Some of the cell values/names are same at ...
4
votes
4answers
722 views

How to make a Bash script to change the format of a date in a CSV file

I've got a series of CSV files whose second field is dates: R.OUSE BOURTON MILL,2000-03-22T14:50:00,Ammoniacal Nitrogen as N,0.03,mg/l How can I change the date format into DD/MM/YYYY for all files? ...
0
votes
0answers
184 views

JSON TO CSV WITH JQ PLAY ERROR

I am new to this. Please forgive me. I am trying to make a CSV file from JSON data. I got far but my data is complex. I am using this line: jq --raw-output '(map(keys) | add | unique) as $cols | ...
0
votes
2answers
108 views

Compare 2 cols; when 1st col > 2nd col, remove 2nd col

How can I compare 2 cols in csv file, divided by ,, and cols contains quotes " when , is present in generated col, and when 2nd col > 1st col, then remove 2nd (last) col. I did something similar, ...
0
votes
1answer
41 views

CSV flies lost when transferred

I changed my OS from Linux to Windows 10 a week back. I saved a few CSV files and some code. After clearing the hard drive and making the switch, I realized that the CSV files were saved in this ...
1
vote
1answer
325 views

How to name the columns in BASH?

I am writing output of 6 UNIX variables into a CSV file. Yes,now I have a CSV file with all the columns that I want.But, I want to use those variable names as column Name/ column Header. How can we ...
-1
votes
1answer
2k views

How to compare two rows in a csv file? [closed]

I've a data.csv file which looks as follows. -1.95e+01 -2.30e-01 -2.56e-01 4.44e+01 -1.95e+01 -2.30e-01 -7.68e-01 4.48e+01 -2.00e+01 -2.30e-01 -2.56e-01 3.41e+01 -2.00e+01 -2.30e-...
0
votes
2answers
1k views

AWK: Sum columns, write them into a “final” row

My CSV looks like this A 5 3 B 3 1 ... I need to get the sum of all columns and add those to a new line in the CSV so it becomes A 5 3 B 3 1 SUM 8 4 I was able to print the sum ...
0
votes
1answer
193 views

System has 32 GB ram but maximum usuage is up to 6 GB

I am using Ubuntu 16.04 (64 bit) and my system has 32 GB RAM. When I run a python (64 bit) program on it, I get a "MemoryError". the output to free -m is: total used free ...
1
vote
3answers
271 views

CSV to TSV without replacing commas within quotes

All the CSV to TSV tutorials are suggesting a simple: tr ',' '\t' though some CSVs look like this: 1,310,"IntAct,PINA" in which case I would like to keep "IntAct,PINA": 1 310 "IntAct,PINA" How ...
0
votes
0answers
128 views

How to avoid reading tabs in a csv file in python?

I've a test.csv file with integers which has columns with different lengths. So the columns which are shorter will have tabs after the last value. For example when I try to print 2nd and 3rd coloumns, ...
0
votes
0answers
119 views

invoice2data table extraction with sub columns

I am working with yml templates using invoice2data to convert pdf to csv. I have a table such as the one below with sub columns: How do I read the subcolumn (for example for subcolumn Rate and ...
0
votes
2answers
48 views

combine the rows to file3 only if the date is present in both files in sorted order of dates and month

My problem is I need to consider the rows to file3 only if the date is present in both files Consider file1.csv dtime,c,y,s 2015-02-01,395,396,g 2015-02-02,395,397,g 2015-02-03,395,397,g This file2....
5
votes
1answer
195 views

Changing second column in csv conditionally

I have a csv file that looks like: data/train/4/36280.png,four data/train/2/10317.png,two data/train/2/57890.png,two data/train/1/53448.png,one data/train/8/58233.png,eight data/train/4/23599.png,...
3
votes
2answers
1k views

MySQL importing CSV files really slow

I am trying to import CSV files into a table, but it has been very slow. I have about 1000 files with a file size of 40 MB each. Whenever I try to import it, I can see with for example MySQL workbench ...
4
votes
1answer
654 views

Libre Office Calc keeps removing quotes

I am opening a .csv file using LibreOffice Calc. However, no matter the format I choose to save the file with after modifying it (either ODF or CSV) for some columns that contained quoted values, the ...
0
votes
2answers
5k views

From XML to CSV with command line

if I have a XML file on local disk, which command is need to convert file in CSV? And from XLSX or XLS to CVS? Thanks.
3
votes
4answers
851 views

Move specific column from csv file in front (select column by name)

Consider this data: #!/usr/bin/env bash cat > example_file.txt <<EOL group, value, price 1, 3.21, 3.21 1, 3.42, 4.11 1, 3.5, 1.22 2, 4.1, 9.2 2, 4.2, 2.11 EOL I want to move the 'value' ...
0
votes
0answers
421 views

csvkit - command line csv viewer and Ubuntu 18.04

Has anyone tried using csvkit in Ubuntu 18.04. I use the command csvlook to view csv files from command line. It used to work in other Ubuntu versions but in 18.04 I get error like the following when ...
0
votes
1answer
1k views

Convert output of shell script to .csv

I want to convert the output of the below patchhistory.sh shell script to csv, so that I can get the information in column format like this: servername patch history ...
2
votes
1answer
574 views

script for csvtool for replacing columns

I want to replace certian columns in a csv file into another and i found this in the csvtoll man page. Which replaces column 1 in the first file with the column 1 in the second file. csvtool ...
1
vote
2answers
75 views

Why Extented Regular expression works on command line input but not when reading from a file

Using Windows 10 developer mode. My regular expression works perfectly when I execute in command prompt. Substitutes mm/dd/yyyy hh:mm to yyyy-mm-dd within a string delimited by comma. It does not ...
3
votes
1answer
900 views

How to combine multiple CSV files to one ods file on the command line. One sheet per original file

How to combine multiple CSV files to one ods file, one sheet per file. I have ten CSV files and I would like to combine them to one ods file comprised of ten sheets, one per original CSV. This should ...
0
votes
0answers
29 views

.csv Translation Error

I trade cryptocurrencies and when I download an exchange trade history for accounting reasons the .csv file has one line of Chinese characters instead of the trades made. I'm using Ubuntu 18.04 LTS. ...
1
vote
1answer
893 views

To manipulate csv file using bash script or python converting certain rows into column

I have to csv file with 6 column , I want to write script using python or bash so that I can generate a new file may be a txtfile where for each rows first three column remains same that is (column 1, ...
1
vote
2answers
2k views

Delete multiple rows in csv file

I'm working on this assignment to delete rows from a CSV file with different customers. I've figured out how to delete one specific customer by using this code: delete() { awk -F "\"*;\"*" '$1 != '$...
2
votes
1answer
6k views

view the column names for CSV file?

i have a CSV file i want to get the columns name for each column sample : how can i do that with awk or sed or grep ??
4
votes
1answer
2k views

column: line too long error

I'm trying to view the first 5 columns from the terminal following this guide here: https://chrisjean.com/view-csv-data-from-the-command-line/ When I run cat rangelast.csv | sed -e 's/,,/, ,/g' | ...
6
votes
3answers
2k views

How to split an ODS spreadsheet file into csv files per sheet on the terminal?

I would like to split a spreadsheet (ods or xlsx) into multiple csv files, one for each sheet in the spreadsheet. I would like to do this without launching a graphical app and preferably in a one ...
3
votes
3answers
380 views

Converting numbers in a CSV file to their corresponding URLs

I have a CSV file with two columns (and a header) where each of its elements includes any number between 0 to 199. I want to convert these to their corresponding URLs. Here is an example: 41,51 ...
1
vote
1answer
511 views

How to compare and replace the value at particular location with awk

I want to compare two csv files with one common column and then replace the data from first file to second file at particular location. file1.csv: "id","name","marks","subject","result" "1","a","","...
1
vote
1answer
459 views

How to copy iphone contacts into a csv file

I want to copy my contacts in a csv file and then later on I want to use them with another icloud account by importing the contacts. I am using ubuntu version 17.10,mobile iphone se Can anyone help me ...
1
vote
0answers
435 views

How can I assign a column to represent the x axis values in libre office calc?

Currently my attempt at making a chart looks like this: The goal, nonetheless Is that subdivisions, should be the x axis and not a series of data entries in the chart. I have looked it up but I am ...
3
votes
2answers
182 views

CSV: concatenate more line data

I have this file1.csv: A,dog cat horse cow B,goat deer fish A,deer goat C,dog cat C,goat I need to merge join the similar lines (es. A and C): A,dog cat horse cow deer goat B,goat deer fish C,...
1
vote
1answer
478 views

Commas from csv only partially imported in Libreoffice Calc

I have a CSV here, generated using Rstudio (front-end for R). When I open it with Libreoffice Calc, the preview in the Text import dialog correctly displays the numbers in the last two columns. There ...
0
votes
2answers
57 views

processing lots of images which have their names stored in a csv file from terminal

How can I copy all the images in the second column of a CSV file and put them to a new folder named images? It has about 300k images so I wonder if there is a fast way to this (like I have 12 ...
10
votes
4answers
5k views

Convert .xls/.xlsx spreadsheets to multiple .csv's based on a list

I need to convert all sheets of a single .xls/.xlsx file to a .csv. This will be done on all .xls files in all directories and sub-directories (recursively). Step 1: Get the sheetnames of all .xls ...
11
votes
2answers
1k views

How can I print sheetnames of a spreadsheet using Linux command-line?

I am aware of using in2csv to save a particular worksheet as a .csv: in2csv --sheet "sheet name" file1.xls > sheet-name.csv But are there any other tools to just print the sheetnames? Perhaps ...
2
votes
4answers
218 views

How to compare two lines in a file?

Let say I have a file foo.csv: timestamp,id,ip_src,ip_dst,protocol,msg 08/20-12:01:22.172612 ,1000001,10.0.0.2,10.0.0.1,ICMP,"ICMP test detected" 08/20-12:03:22.172809 ,1000001,10.0.0.6,10.0.0.3,...
2
votes
2answers
661 views

Sum column 2 of .csv file if column 1 is the same

I have a csv file where column 1 is the name of a gene and column 2 is a value associated with that gene. However, some genes have multiple values and I want to sum the values of column 2 if column 1 ...
2
votes
2answers
9k views

Bash script to edit excel files

I have multiple excel files in this format. They are clock in and clock out date and time. --------------------------------- | Name | Time | --------------------------------- | ...