Find out the Number of Columns in Flat File

In ETL testing if the src is flat file, then how will you verify the data count validation?

Questions by kishore.vakalapudi

Showing Answers 1 - 16 of 16 Answers

32kris

  • Aug 11th, 2010
 

The metadata is always on the top row in a flat file. the delimiters (,or ; or @)seperate each columns metadata.

  Was this answer useful?  Yes

bhargav

  • Aug 30th, 2011
 

by using "WC" unix command we can find the count of a file


syntax:
wc file name

  Was this answer useful?  Yes

sadashiv_dwh

  • Sep 3rd, 2011
 

I assume your source flat file is on UNIX box and the first row has column name seperaetd by space - then -

$ head -1 | wc -w


  Was this answer useful?  Yes

Vinay Reddy

  • Feb 9th, 2012
 

Generally, the flat file data is populated into the table and then loaded into the target based on transformations. It would then be the same process how we validate the data. Pls correct me if am not correct...

  Was this answer useful?  Yes

Radhakrishna

  • Nov 13th, 2013
 

To find the count in flat file, you have to import that file into excel sheet (use Data->Import External Data->import data) and find the count of records using count() [goto Insert->function->count->] in excel....

  Was this answer useful?  Yes

JeffManson

  • Feb 13th, 2014
 

Not always (in my experience, quite rarely in fact). Most often the flat file is just that, a flat file. If in UNIX, the wc command is great, in Windows, one could open the file in notepad and CTRL+END to the last row wherein one will see the row count, or, as stated below, use Excel. Or you could just have your ETL program count for you. Those methods vary based on which ETL software you are using (SSIS, Informatica, etc)

  Was this answer useful?  Yes

himanshu rathore

  • Jan 24th, 2015
 

If the files is on UNIX and delimiter separated, then we an use utility awk for that. Below is the command:
awk -F: END { print NF} filename.

Note: file in current directory and : separated fields.

  Was this answer useful?  Yes

santhosh gujja

  • Oct 15th, 2015
 

1) If the source is a flat file. First we need to convert into the excel sheet.
2) Create a sample table with the same table structure as of the source file and load the flat file into it.

  Was this answer useful?  Yes

sandeep

  • Dec 29th, 2015
 

Generally, the flat file data is populated into the table and then loaded into the target based on transformations. It would then be the same process how we validate the data. Pls correct me if am not correct.

  Was this answer useful?  Yes

Deepthi

  • Jun 14th, 2016
 

If source is flat file, we can extract the data in to table. Using Informatica developer and can get the count. Correct me if I am wrong.

  Was this answer useful?  Yes

vineeta

  • Aug 9th, 2016
 

If the files have delimiter then open the file with excel in delimited mode and then ctrl+shift+end gives no. of records count

  Was this answer useful?  Yes

shivam

  • Sep 22nd, 2016
 

Your question has two different things to look for -
1. To count number of columns in flat file (You can open flat file in excel and count columns as Vineeta answered. or you can write a command in Unix to check number of delimiters)
2. To check number of records in a flat file (use unix command wc -l).
2. To count number of records in a file

  Was this answer useful?  Yes

Sridhar

  • Jan 5th, 2017
 

cat | grep ";" | wc -l
Use this unix command to get the no of ";" in the file file_name

  Was this answer useful?  Yes

Abdul khadar

  • Apr 20th, 2017
 

If you want to know the number of rows in a file:
1: If the file has header and you want to no of rows in a file : sed 1d filename | wc -l (IN UNIX BOX)

2: If the file has no header and you want to no of rows in a file: wc -l filename

  Was this answer useful?  Yes

Shivnath Rojatkar

  • May 12th, 2017
 

Using wc command in UNIX, you can check the count of records.

  Was this answer useful?  Yes

Divya Jain

  • May 16th, 2017
 

Say file Name: abc.txt and delimited with a comma(,)
answer:
hear -1 abc.txt | awk -F "," {print $NF}

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions