Saved Bookmarks
| 1. |
Solve : CSV file to grep required data? |
|
Answer» Hi , Hi , 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
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. |
|