[Pugged] Coding Questions
ciapug@ciapug.org
ciapug@ciapug.org
Wed, 26 Feb 2003 14:26:43 -0000
Chris Hettinger <cjh@raccoon.com> said:
> [This may come a second time, damn email delays]
>
> I have a db table that I periodically need to update with a new set of
> data. To do this I run a script to empty and reload the table with the
> contents of a comma separated value text file. I am working on
> automating that a little bit and have a question...
>
> The text file that I receive to upload has a line, the first line
> specifically, that I need to trim off before the reload happens. The
> line is just the field names inserted when it is output from another
> table, the line is useless and will cause errors if I simply to a reload
> based on this text file with it in there. Example:
>
> "id","LocationID","StatusID","KeywordDesc","Zip" <--------- Trim this
> line.
> 5555,55555,"P","KeywordDesc","50309"
>
> I haven't yet done much with file access (fopen...) and to be honest I
> am not sure what this problem requires to solve, thought I think I need
> to open the file, trim the line, then close the file before doing the
> reload with it...
>
> If anyone could nudge me in the right direction I would greatly
> appreciate it.
>
Check whatever app is writing your CSV export file. There may be an
option to leave off the header row. If it's coming from an MS-SQL
server job you can do that... if it's from Access... well, I don't
"do" Access enough to tell you.
On the linux side, there's several tools that could do scripting job
to trim it... or you could probably do it from PHP before you import it.
-dc