Hi everyone,
I have looked around for a solution to this, but I cannot seem to find anything about it.
I would like to know if it is possible to read a file, over FTP (this is a must), line-by-line. The Net::FTP package will allow me to "get" entire files, and the "read" function does not appear to have a parameter for a file. There are other packages, like File::Remote, which allow line-by-line reading of remote files, but do not support FTP.
The problem that I am trying to solve is this. I have a very large list of files (indexed by company and year). Each company and year combination has multiple files associated with it. However, I know that I only want one of these files; I just can't tell which one from the listing. In order to tell if a particular file is the correct one, I need to read the header of the file (the files are .txt, but have HTML information in them which includes a header).
I would like to write a script which iterates over each filename in the list and retrieves each one from the FTP server one line at a time. I can then check each line to see if it contains the header information that I need, and I can exit the read if it does. Alternately, if line-by-line is not doable, I could extract a fixed number of lines from each file: the header does not always contain the same number of lines, but I could pick a threshold which would work.
These files are individually quite large, so I only want to download the ones that I need. Otherwise, I would download all the files and delete the ones that did not match.
Any help would be appreciated!
Matt
In reply to Read part of a file over FTP by ronin78
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |