|
Posted by Michael on December 9, 2008, 12:05 pm
Please log in for more thread options
Hi all,
I wonder what is the best way to remove comments from txt file. I have
pretty big (about 100mb) .txt file with some comment lines at
beginning and want to clean it up. My first idea was to read file with
fget and if line does not begin with # write to new file, then rename.
Is it possible to do that without reading hole file?
Thanks for your help!
|
|
Posted by 703designs on December 9, 2008, 12:18 pm
Please log in for more thread options
show/hide quoted text
> Hi all,
> I wonder what is the best way to remove comments from txt file. I have
> pretty big (about 100mb) .txt file with some comment lines at
> beginning and want to clean it up. My first idea was to read file with
> fget and if line does not begin with # write to new file, then rename.
> Is it possible to do that without reading hole file?
> Thanks for your help!
Just curious, what's the application of this? Maybe you should be
using Awk.
Thomas
|
|
Posted by Michael on December 9, 2008, 12:38 pm
Please log in for more thread options show/hide quoted text
> > Hi all,
> > I wonder what is the best way to remove comments from txt file. I have
> > pretty big (about 100mb) .txt file with some comment lines at
> > beginning and want to clean it up. My first idea was to read file with
> > fget and if line does not begin with # write to new file, then rename.
> > Is it possible to do that without reading hole file?
> > Thanks for your help!
> Just curious, what's the application of this? Maybe you should be
> using Awk.
> Thomas
it is import of tab delimited file into db. Actually there are also
some small files for that task, but some of them are really big.
|
|
Posted by houghi on December 9, 2008, 2:13 pm
Please log in for more thread options Michael wrote:
show/hide quoted text
> Hi all,
> I wonder what is the best way to remove comments from txt file. I have
> pretty big (about 100mb) .txt file with some comment lines at
> beginning and want to clean it up. My first idea was to read file with
> fget and if line does not begin with # write to new file, then rename.
> Is it possible to do that without reading hole file?
If it is only one file, why not do it by hand?
houghi
--
This was written under the influence of the following:
| Artist : Jimi Hendrix
| Song : Voodoo Child (Slight Return)
| Album : Band Of Gypsys_ Live At The Fillmore East
|
|
Posted by 703designs on December 9, 2008, 2:36 pm
Please log in for more thread options show/hide quoted text
> Michael wrote:
> > Hi all,
> > I wonder what is the best way to remove comments from txt file. I have
> > pretty big (about 100mb) .txt file with some comment lines at
> > beginning and want to clean it up. My first idea was to read file with
> > fget and if line does not begin with # write to new file, then rename.
> > Is it possible to do that without reading hole file?
> If it is only one file, why not do it by hand?
> houghi
> --
> This was written under the influence of the following:
> | =A0Artist : Jimi Hendrix
> | =A0 =A0Song : Voodoo Child (Slight Return)
> | =A0 Album : Band Of Gypsys_ Live At The Fillmore East
Right. In an editor that has Regex find/replace (like vim):
:%s/^#.*$//g
will remove all lines that begin with #
Thomas
|
| Similar Threads | Posted | | Remove trailing blank lines at the end of a file | March 30, 2009, 9:51 am |
| remove all lines starting with b | March 26, 2006, 9:23 pm |
| Going With a Flat-File DB for a Simple Comment Form | May 10, 2006, 2:31 pm |
| Remove duplicate entries from TXT file ? | January 16, 2005, 6:31 pm |
| Skip lines in txt-file | October 11, 2004, 11:54 am |
| Using File() with blank lines | June 4, 2005, 2:21 pm |
| Read first 10 lines from a file | August 19, 2005, 12:50 pm |
| edit lines in txt file | April 24, 2007, 8:54 pm |
| Newbie: How to loop through lines in a file? | December 15, 2004, 3:25 am |
| reading multi-lines in a file... | March 25, 2006, 4:41 am |
|
> I wonder what is the best way to remove comments from txt file. I have
> pretty big (about 100mb) .txt file with some comment lines at
> beginning and want to clean it up. My first idea was to read file with
> fget and if line does not begin with # write to new file, then rename.
> Is it possible to do that without reading hole file?
> Thanks for your help!