Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Extract a certain field from a CSV? Post 302497197 by chickeneaterguy on Wednesday 16th of February 2011 02:33:39 PM
Old 02-16-2011
Thanks, is there a way I could do it with writing:
Code:
awk -F, '{(if $2 == 1940) print $3}' > gender.txt

note: I'd be writing this into a file/script then running it as a parameter. Say the above code is titled genderExtract.sh, could I do this:

Code:
sh genderExtract.sh listofpeeps.csv

EDIT: I'm just doing this to get the gist of using -F and I don't want to do it through command line. I don't need to make a program to extract genders...but I could see that being useful for surveying purposes.
 

10 More Discussions You Might Find Interesting

1. Linux

Replace field in csv

Hi, I need to replace a field (field 5) in a csv file, based on the content of another field (field 2), something like this: actual file: field1, field2, filed3, field4, field5, field6 01,232,abb-pan,679,,pan 02,565,cdf-pan,683,,pan the result should be: ... (4 Replies)
Discussion started by: pcboss
4 Replies

2. UNIX for Dummies Questions & Answers

How to insert ' in a field in CSV file

print "count,pub,prodline,group,sector,date,source" > $fname cat sp_log.summary.$firstday-$lastday.ProdlineSector | sed "s/^ *//g;s/ *$//g" >sp_log.summary.$firstday-$lastday cat sp_log.summary.$firstday-$lastday | sed "s/$/ $lastyy-$lastmm cache/;s/ /,/g" >> $fname cat $fname | sed... (1 Reply)
Discussion started by: shikhakaul
1 Replies

3. Shell Programming and Scripting

replace a field in a CSV file

Hello all, I've a CSV file and need to replace 5th field if its value is "X". The exact requirement is to replace 5th field (column) with "Y" if a. it's value is "X" AND b. the line must start with ABC string i guess this can be done with awk. Pl help. For security reasons, the... (2 Replies)
Discussion started by: prvnrk
2 Replies

4. Shell Programming and Scripting

Extract Values from CSV

Hi, I need to extract values from a CSV file based on some conditions as explained below: File format details: 1. each set starts with AAA only 2. number of columns is fixed 3. number of rows per set may vary (as they are having different CCC rows) Now, i need to extract 3rd column of... (3 Replies)
Discussion started by: prvnrk
3 Replies

5. Shell Programming and Scripting

extract .csv file

Hi all I am new to unix . I need to write a script that extracts some data from oracle into a .csv file with heading of the columns in the file SO i created the following two scripts but they are not working ac.sql (this is the sql file that i will call inside the shell script when i run... (1 Reply)
Discussion started by: rajesh_tns
1 Replies

6. Shell Programming and Scripting

extract data in a csv file based on a certain field.

I have a csv file that I need to extract some data from depending on another field after reading info from another text file. The text file would say have 592560 in it. The csv file may have some data like so Field 1 Field2 Field3 Field4 Field5 Field6 20009756 1 ... (9 Replies)
Discussion started by: GroveTuckey
9 Replies

7. Shell Programming and Scripting

Extracting field values from .csv

How can I select the bold fields from the following? "CLLI","SWREL","RPTDATE","RPTIME","TZ","RPTTYPE","RPTPD","IVALDATE","IVALSTART","IVALEND","NUMENTIDS" "tklc9010801","EAGLE5 45.0.0-64.70.1","2013-08-07","02:01:50","MST ","COMPONENT MEASUREMENTS ON... (4 Replies)
Discussion started by: leghorn
4 Replies

8. Shell Programming and Scripting

Update field value on a csv file

Hi I have a job status csv file. I want to update the status of the job in the file. Below is the csv file 1,jobname1,in_progress,starttime,somthing,somthing 2,jobname2,completed,starttime,somthing,somthing 3,jobname3,failed,starttime,somthing,somthing... (8 Replies)
Discussion started by: midhun19
8 Replies

9. Linux

How do I format a Date field of a .CSV file with multiple commas in a string field?

I have a .CSV file (file.csv) whose data are all enclosed in double quotes. Sample format of the file is as below: column1,column2,column3,column4,column5,column6, column7, Column8, Column9, Column10 "12","B000QRIGJ4","4432","string with quotes, and with a comma, and colon: in... (3 Replies)
Discussion started by: dhruuv369
3 Replies

10. Shell Programming and Scripting

Match columns from two csv files and update field in one of the csv file

Hi, I have a file of csv data, which looks like this: file1: 1AA,LGV_PONCEY_LES_ATHEE,1,\N,1,00020460E1,0,\N,\N,\N,\N,2,00.22335321,0.00466628 2BB,LES_POUGES_ASF,\N,200,200,00006298G1,0,\N,\N,\N,\N,1,00.30887539,0.00050312... (10 Replies)
Discussion started by: djoseph
10 Replies
PORTABASE(1)						      General Commands Manual						      PORTABASE(1)

NAME
portabase - an easy-to-use personal database application SYNOPSIS
portabase [ -h | --help | <file> ] portabase command [ -p password ] [ options ] <fromfile> <tofile> DESCRIPTION
PortaBase (portable database) is a personal database application that is available for many platforms, including Linux, Mac OS X, Windows, and Maemo. PortaBase's features include: - One data table per file - String, Integer, Decimal, Boolean, Note (multi-line text), Date, Time, Calculation, Sequence, Image, and Enum column types - Add, edit, and delete rows of data - Custom data views (subsets of the columns in any order) - Filter the displayed rows using sets of conditions - Sort the rows by any combination of columns, each in ascending or descending order - Optional page navigation buttons, with a custom number of rows per page - Add, delete, rearrange, and rename columns at any time - Specify default values for columns - View summary statistics for columns (total, average, min, max, etc.) - Import data from CSV, XML, and MobileDB files - Export data to CSV and XML files - Command-line format conversions (to and from XML, from MobileDB) - Data file encryption - Unicode support - Pick any available font to use throughout the application COMMANDS
PortaBase uses the following commands to indicate a command-line file conversion: fromxml Create a new PortaBase file from the input XML file. frommobiledb Create a new PortaBase file from the input MobileDB file. fromcsv Add rows to an existing PortaBase file from the input CSV file. toxml Create a new XML file from the input PortaBase file. tocsv Create a new CSV file from the input PortaBase file. If an encrypted PortaBase file is to be read or created, the following option can be used immediately after the command: -p <password> Open or create the encrypted PortaBase file using the given password The toxml and tocsv commands accept the following options: -v <view> Apply the named view before exporting. -s <sorting> Apply the named sorting before exporting. -f <filter> Apply the named filter before exporting. The fromcsv command supports one option: -e <encoding> Specifies the text encoding of the imported CSV file; options are UTF-8 (the default) and Latin-1. OPTIONS
PortaBase accepts the following options: -h, --help Display usage instructions. FILES
$HOME/.qt/portabaserc - user-specific settings. Stores information on font, checkbox editing, delete confirmations, etc. AUTHOR
This manual page was written by Jeremy Bowman <jmbowman@alum.mit.edu>, for the Debian GNU/Linux system (but may be used by others). April 16, 2010 PORTABASE(1)
All times are GMT -4. The time now is 05:54 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy