--- In [email protected], "Steve Nelson" <[EMAIL PROTECTED]> wrote:
> I have hundreds of CSV files to read, but the field names start on
the
> second line, not the first. So not only to I want to skip the first
> two lines of every file when reading for data, I want to use the
field
> names located on the second line. Can't seem to see a way to specify
> the line that holds the field name other than only being able to
> select the first line.
>
> Can anyone suggest a work around, or can I suggest this option be
> added to a future build?
>
> I'm running build 1314
> Thanks
> Steve
Hi Steve
I would make new textfiles.
You have already got an answer, but this little helper can solve your
problem and can perhaps be useful to others. It's just plain DOS's FOR
command and can be extended with use of token etc.
Not at all FME, here it is anyway:
1:3 Copy and paste this into your text editor:
:: *** START_SKIP.BAT ***
::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Starts skip.bat
:: Makes copies of textfiles with starting lines skipped.
:: Variables are set below, if there is a need to
:: to add lines to destination file, se skip.bat.
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::
@echo off
::
::------ Variables
::--- Number of rows you want to skip.
SET rows2skip=1
::--- Path to your source files.
SET srce_lib=c:\temp\test
::--- Extension of your source files.
SET srce_ext=csv
::--- Path to your destination files.
SET dest_lib=c:\temp\test\skipped
::--- Name suffix for your destination files (if none wanted, just
leave the dot).
SET dest_suf=_skipped.
::--- Extension of your destination files.
SET dest_ext=txt
::
FOR %%a IN (%SRCE_LIB%\*.%SRCE_EXT%) DO CALL skip.bat %%a %ROWS2SKIP% %
DEST_LIB% %DEST_SUF% %DEST_EXT%
::
ECHO **********************************
ECHO Done skipping, hit any key to quit.
pause > nul
::
:END
and save as: start_skip.bat
2:3 Open a new file in your text editor.
Copy and paste this:
:: *** SKIP.BAT ***
::
:::::::::::::::::::::::::::::::::::::
:: Started by start_skip.bat
:: Se below how to add lines.
:::::::::::::::::::::::::::::::::::::
::
::--- Deletes existing destination file.
IF EXIST %3\%~n1%4%5 DEL /Q %3\%~n1%4%5
::--- Message on screen.
ECHO %1 Skipping first %2 row(s) into %3\%~n1%4%5
::--- Adding new lines to the beginning of destination file.
:: (Uncomment lines containing ECHO to use)
::>> %3\%~n1%4%5 ECHO My first line
::>> %3\%~n1%4%5 ECHO My second line
:: and so on...
::
::--- The skipping.
FOR /F "skip=%2 delims=" %%a IN (%1) DO ECHO %%a >> %3\%~n1%4%5
::
::--- Adding new lines to the end of destination file.
:: (Uncomment lines containing ECHO to use)
::>> %3\%~n1%4%5 ECHO My second to last line
::>> %3\%~n1%4%5 ECHO My last line
:: and so on...
::
:END
and save as: skip.bat
3:3 Check the settings and run start_skip.bat
Regards
HÃ¥kan
Get the maximum benefit from your FME, FME Objects, or SpatialDirect via our
Professional Services team. Visit www.safe.com/services for details.
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/fme/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/