Sponsored Content
Top Forums Shell Programming and Scripting How to find number of Cols in a file ? Post 302306312 by videsh77 on Sunday 12th of April 2009 09:46:07 AM
Old 04-12-2009
How to find number of Cols in a file ?

Hi

I have a requirement wherein the file is comma separated. Each records seems to have different number of columns, how I can detect like a row index wise, how many columns are present ?

Thanks in advance.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

join cols from multi files into one file

Hi Fields in Files 1,2,3,4 are pipe"|" separated. Say I want to grep col1 from File1 col3 from File2 col4 from File3 and print to File4 in the following order: col3|col1|col4 what is the best way of doing this? Thanks (2 Replies)
Discussion started by: vbshuru
2 Replies

2. Shell Programming and Scripting

find the highest number in the file

Hi, I have a file a.txt and it has values in it Eg :- I need to read through the file and find the number that is the greatest in them all. Can any one assit me on this. Thanks (30 Replies)
Discussion started by: systemali
30 Replies

3. Shell Programming and Scripting

How to find number of lines in a file

Hi How do I find number of lines of a file? Below commands returned 0. But, the file is showing 20 lines when I open it in editplus tool. Each line contains 601 columns. Please advise I want to incorporate some word at the begining of each of those 20 lines -Somesh $ wc -l <... (2 Replies)
Discussion started by: somesh_p
2 Replies

4. Shell Programming and Scripting

How to find the number of column in the text file...?

Hi, i have text file with ~ seperated columns. it is very huge size of file, in the file sompulsary supposed to has 20 columns with ~ seperated. so how can i find if the file has 20 column in the all rows...? Sample file: APA+VU~10~~~~~03~101~101~~~APA.N O 20081017 120.00... (1 Reply)
Discussion started by: psiva_arul
1 Replies

5. UNIX for Dummies Questions & Answers

Find number of columns in a file

Hi all, may seem a very stupid question.but me stuck up in it for long.... How to find the number of columns in a ASCII file. EX:-Demo.lst songs 1 34 45 67 Number of columns should be 5. Regards, Anindya ;) (13 Replies)
Discussion started by: rahul26
13 Replies

6. Shell Programming and Scripting

Perl find page number in a file

Hi i want to ask how can i use perl and find a word in a text file, and also telling that which page doesn't it exist? Eample: have a 10 pages text file, then i need to find 'Hello' in the file, and show that which page is it contain in. Output: Hello contains 8 times in page 1, 3, 4, 7, 10... (9 Replies)
Discussion started by: mingming88
9 Replies

7. Shell Programming and Scripting

sort and split file by 2 cols (1 col after the other)

Dear All, I am a newbie to shell scripting so this one is really over my head. I have a text file with five fields as below: 76576.867188 6232.454102 2.008904 55.000000 3 76576.867188 6232.454102 3.607231 55.000000 4 76576.867188 6232.454102 1.555146 65.000000 3 76576.867188 6232.454102... (19 Replies)
Discussion started by: Ghetz
19 Replies

8. Programming

Help with find highest and smallest number in a file with c

Input file: #data_1 AGDG #data_2 ADG #data_3 ASDDG DG #data_4 A Desired result: Highest 7 Slowest 1 code that I try but failed to archive my goal :( #include <stdio.h> (2 Replies)
Discussion started by: cpp_beginner
2 Replies

9. Shell Programming and Scripting

how to Insert values in multiple lines(records) within a pipe delimited text file in specific cols

this is Korn shell unix. The scenario is I have a pipe delimited text file which needs to be customized. say for example,I have a pipe delimited text file with 15 columns(| delimited) and 200 rows. currently the 11th and 12th column has null values for all the records(there are other null columns... (4 Replies)
Discussion started by: vasan2815
4 Replies

10. Programming

Find the number in the file

In my system , there are text files will be generated monthly , the file name begins with xxx , then year , month ( for example xxxxx201310.txt means Oct 2013 ) I have below command to count how many abc in the month , but it only count the number in this month . NUMBER=$(cat xxxxx201310.txt... (2 Replies)
Discussion started by: ust
2 Replies
DBS_UPDATE(1p)						User Contributed Perl Documentation					    DBS_UPDATE(1p)

NAME
dbs_update - Update SQL Databases DESCRIPTION
dbs_update is an utility to update SQL databases from text files. FORMAT OF THE TEXT FILES dbs_update assumes that each line of the input contains a data record and that the field within the records are separated by tabulators. You can tell dbs_update about the input format with the --format option. The first field of the data record is used as table specification. These consists of the table name and optionally the index of starting column, separated by a dot. Alternatively dbs_update can read the column names from the first line of input (see the -h/--headline option). These can even be aliases for the real column names (see the -m/--map option). COMMAND LINE PARAMETERS
Required command line parameters are the DBI driver ("Pg" for Postgres or "mysql" for MySQL) and the database name. The third parameter is optionally and specifies the database user and/or the host where the database resides ("racke", "racke@linuxia.de" or "@linuxia.de"). OPTIONS
--cleanse Removes all records which remain unaffected from the update process. The same result as deleting all records from the table first and then running dbs_update, but the table is not empty in the meantime. -c COLUMN,COLUMN,..., --columns=COLUMN,COLUMN,... Update only the table columns given by the COLUMN parameters. To exclude columns from the update prepend "!" or "^" to the parameters. --rows=ROW,ROW,... Update only the input rows given by the ROW parameters. The first row is 1 where headlines doesn't count. To exclude rows from the update prepend "!" or "^" to the parameters. -f FILE, --file=FILE Reads records from file FILE instead of from standard input. --format=FORMAT[SEPCHAR] Assumes FORMAT as format for the input. Only CSV can be specified for now, default is TAB. The default field separator for CSV is a comma, you may change this by appending the separator to the format. -h, --headline Reads the column names from the first line of the input instead of dedicting them from the database layout. Requires the -t/--table option. -k COUNT, -k KEY,KEY,..., --keys=COUNT, --keys=KEY,KEY,... Specifies the keys for the table(s) either as the number of columns used as keys or by specifying them explicitly as comma separated argu- ments to the option. This is used for the detection of existing records. -m ALIASDEF, --map=ALIASDEF Maps the names found in the first line of input to the actual column names in the database. The alias and the column name are separated with "=" signs and the different entries are separated by ";" signs, e.g. "Art-No.=code;Short Description=shortdescr'". --map-filter=FILTER Applies a filter to the column names read from the input file. Currently there is only the "lc" filter available. --match-sql=FIELD:{STATEMENT} Updates only records where the value of the column FIELD is in the result set of the SQL statement STATEMENT, e.g. "category:{select dis- tinct name from categories}". -o, --update-only Updates existing database entries only, stops if it detects new ones. -r ROUTINE, --routine=ROUTINE Applies ROUTINE to any data record. ROUTINE must be a subroutine. dbs_update passes the table name and a hash reference to this subrou- tine. The keys of the hash are the column names and the values are the corresponding field values. If the return value of ROUTINE is not a truth value, the data record will be skipped. "sub {my ($table, $valref) = @_; unless (defined $$valref{country} && $$valref{country} !~ /S/) { $$valref{country} = "Germany"; } 1; }" --skipbadlines Lines not matching the assumed format are ignored. Without this option, dbs_update simply stops. -t TABLE, --table=TABLE Uses TABLE as table name for all records instead of the first field name. AUTHOR
Stefan Hornburg (Racke), racke@linuxia.de SEE ALSO
perl(1), DBIx::Easy(3) perl v5.8.8 2007-02-01 DBS_UPDATE(1p)
All times are GMT -4. The time now is 08:58 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy