Skip to content
Advertisement

Tag: csv

Add an index column to a csv using awk

How can I add an index to a csv file using awk? For example lets assume I have a file data.txt I would like to add another column, which is the index. Basically I would like an output of I was trying to use awk ‘{for (i=1; i<=NF; i++) print $i}’ but it does not seem to be working right.

Combine multiple files csv into one using awk

I want to combine two .csv files based on the unique id that exists in both files. First file consist of 17 columns and the second one in 2 columns where in both files the first column is the same unique id. In the to be created file 3 i would like 18 columns. I have been trying paste paste

Unzip part of file

Is there a way to unzip part of a .gz file without having to unzip it all? I have a large (~139Gb) zipped .csv.gz file. I have been told that the .csv file has ~540M rows of data. I only need to access a sample of the data in the .csv file and I would be happy for it to

using only ‘grep’ command to get specific column

This below shows this some lines of csv file, i want to get the results that only get the Population column with only using grep command. results i want: The command i made for this problem was which got results below how can i get rid of the rest of things without using awk sed or any other things? Answer

Move all rows in a tsv with a certain date to their own file

I have a TSV file with 4 columns in this format The 4th column is a date string Example : 2020-12-09 12:34:22 I want every row with the same date to go into its own file For example, file 20201209 should have all rows that start with 2020-12-09 in the 4th column file 20201210 should have all rows that start

how to read csv files with mbcs codec in Python on Linux?

I’m trying to read CSV files with Western Europe (windows) encoding This code works well on Windows but not on Linux 18.04. (Error: unknown encoding: mbcs) Indeed, in the codecs python documentation, we have the information: is there another way/name to decode my files in python on Linux? (I have thousand of files so I can’t save as on Excel)

replace numbers smaller than certain threshold with zero

I have a large data sheet (see below) in .csv format. I want to replace the numbers in each column and row with zero if it is smaller than a certain value, let’s say 0.1. Could anyone give me a hand? Thanks a lot. I guess it can be done with sed as in this example Answer Here is one

Convert CSV to TSV

How do you convert this csv file into a tab delimited file? Notice both the Surverys and Response columns are empty strings. I use this code to convert it to a tab file – It doesn’t convert the last column though. This is the output I get (Notice the last column is omitted) – There are 8 columns in the

Advertisement