Import question

Bob Stockler bob at trebor.iglou.com
Tue Mar 21 12:01:38 PST 2006


Mark Luljak wrote (on Mon, Mar 20, 2006 at 04:01:21PM -0500):

| Y'all catch dis heeyah?  Don Coleman been jivin' 'bout like:
| > I have an import process that imports a text file via Windows Task scheduler
| > every 4 minutes.  Following is the beginning of one line copied from that
| > text file which will not import.
| > 
| > 06914995:02:47:42 PM: :SMC:	(copied/pasted from the imported text file)
| > 
| > This is a colon field-delimited file.  My filePro import process stops
| > reading data after the apparent blank space after the "PM:".  My hex editor
| > says this field contains a hex 00 NUL and each variable after this field
| > shows as a blank value.  The import process then continues as expected
| > beginning with the next record (NL).  This problem arose after a software
| > update to the alien application creating the file.  They have been unable to
| > explain or correct the issue on their end so it looks like I have to program
| > around it.  This happens in a limited number of random records (1-10/day)
| > out of up to 25,000 records in the file.  Any suggestions on how to program
| > around this so the file does not have to be manually edited.  In order to
| > fix presently you must open the file with a text editor and delete that
| > "invisible" character.  It then imports correctly.  
| 
| You just want to strip out every NULL in every line?
| 
| 
| #!/usr/bin/perl
| foreach my $line (<>) {
|      $line =~ s/\000//g;
|      print(${line});
| }
| exit;
| 
| 
| Save that program, mode it 755, pipe your data through it or call it with
| the data file path as an argument (either works), and redirect the output
| to a new file.
| 
| I'd have used sed, but I can't honestly remember how to represent a null to
| sed off the top of my head.  Same concept, I just don't use sed much since
| I'm in perl so often.  I have $0.01 that says Bob Stockler gives you an
| awk solution that does the same thing, and JPR can readily produce the sed
| version.  :)

All flavors of AWK except "gawk" choke on NUL characters in
their input.  I think "tr" would be my choice for this task.

Bob

-- 
Bob Stockler  +-+  bob at trebor.iglou.com  +-+  http://members.iglou.com/trebor
Author: MENU EDIT II - The BEST Creator/Editor/Manager for filePro User Menus.
Fully functional (time-limited) demos available by email request (specify OS).


More information about the Filepro-list mailing list