Archivio Domande

Linux - Delete .csv column

Before you start you need to install

Ubuntu - sudo apt-get install libtext-csv-perl

CentOs - sudo yum install perl-Text-CSV


Then you need to download our script and assign the correct permissions. Place this script in the same folder your .csv files are in

wget http://195.154.61.188/script/deletecolumn.perl
chmod +x deletecolumn.perl

After downloading you need to edit the line below in deletecolumn.perl

print "\"$column[0]\",\"$column[2]\"\n";

By default this will only keep columns 0 and 2 (A and C, domainName and contactEmail)

0 = Column A
1 = Column B
2 = Column C
3 = Column D and so on...

Once you've edited it you need to run it using the following command

./deletecolumn.perl YourFileName.csv > YourNewFileName.csv

Hai trovato questa risposta utile?

 Stampa Articolo

Leggi anche

Linux - How to split large file

For this example we will split a large .csv into multiple files each "X" megabytes in size....

Linux - How to only keep X data

Firstly to start this you need to convert your .csv into a .txt mv filename.csv  filename.txt...

Linux - How to delete .csv file containing "X" data

After extracting the .csv.gz files you can delete certain unwanted data by running the following...

Linux - How to combine multiple .csv files

To combine multiple files with the letters "2014" and "2015" in their name run the following...

Linux - Delete lines with duplicate data

If for example you dont want the same email address to be in your .csv files you would run the...