1.

Solve : CSV file to grep required data?

Answer»

Hi ,

I am having more than 50 csv files.I need to read datas from that files and grep date and number of lines in that files.Then I need to append in outfile file. Can you please help me out in DOS script.
Quote from: GOKUL on July 07, 2010, 01:20:07 AM

Hi ,

I am having more than 50 csv files.I need to read datas from that files and grep date and number of lines in that files.Then I need to append in outfile file. Can you please help me out in DOS script.




C:\test>type gok.bat
@echo off
dir /b /s *.csv > csvfiles.txt
for /f "delims=" %%i in (csvfiles.txt) do (
findstr "AM" %%i
grep AM %%i
echo count
rem findstr "AM" %%i | wc -l
findstr "AM" %%i | find /c /v ""
)

Output:

C:\test>gok.bat
08:09 AM
08:09 AM
File C:\test\timefile4.csv_processed_06302010:
08:09 AM
08:09 AM
count
2
08:09 AM
08:09 AM
File C:\test\timefile3.csv_processed_06302010:
08:09 AM
08:09 AM
count
2
08:09 AM
08:09 AM
File C:\test\timefile2.csv_processed_07012010:
08:09 AM
08:09 AM
count
2
08:09 AM
08:09 AM
File C:\test\timefile1.csv_processed_06302010:
08:09 AM
08:09 AM
count
2
08:09 AM
08:09 AM
File C:\test\timefile4.csv_processed_07012010:
08:09 AM
08:09 AM
count
2
08:09 AM
08:09 AM
File C:\test\timefile1.csv_processed_07012010:
08:09 AM
08:09 AM
count
2
08:09 AM
08:09 AM
File C:\test\timefile2.csv_processed_06302010:
08:09 AM
08:09 AM
count
2
08:09 AM
08:09 AM
File C:\test\timefile3.csv_processed_07012010:
08:09 AM
08:09 AM
count
2
08:09 AM
08:09 AM
File C:\test\timefile1.csv:
08:09 AM
08:09 AM
count
2
08:09 AM
08:09 AM
File C:\test\timefile2.csv:
08:09 AM
08:09 AM
count
2
08:09 AM
08:09 AM
File C:\test\timefile3.csv:
08:09 AM
08:09 AM
count
2
08:09 AM
08:09 AM
File C:\test\timefile4.csv:
08:09 AM
08:09 AM
count
2

C:\test>Hi Marvin,

I need to grep the date throught Date FORMAT , not using AM or PM.My current date format is MM/DD/YYYY.
I need to grep dates LIKE this format.

Thanks
Quote from: Gokul on July 07, 2010, 04:11:12 AM

I need to grep the date throught Date format , not using AM or PM.My current date format is MM/DD/YYYY.
I need to grep dates like this format.

Thanks




C:\test>type gok2.bat
@echo off
set /p grepdate=Please enter grep date (mm/dd/yyyy):
dir /b /s *.csv > csvfiles.txt
for /f "delims=" %%i in (csvfiles.txt) do (
findstr "AM" %%i
grep AM %%i
grep %grepdate% %%i
echo count
rem findstr "AM" %%i | wc -l
findstr "AM" %%i | find /c /v ""
)

Output:

C:\test> gok2.bat
Please enter grep date (mm/dd/yyyy): 05/06/2010

______________________________

p.s. Please post the code you are using and any error messages.

Please post an example of the csv file where you will grep for mm/dd/yyyy.

With the above information we can decide what NEEDS to done.


Discussion

No Comment Found