T
Todd Burch
This is weird. I have a script I've written to reformat a file for this
guy. It works perfect on my Mac, but not on his.
This was a quick and dirty script to reformat an ascii file. It parses
the fixed length records and writes the output in a tab delimited
format. No big deal.
I had hard coded the file name in the script, and sent it to him, to
edit and type in the correct path names for the input and output files,
and now it does not work for him.
This is the error he gets:
Last login: Sat Jun 14 16:57:06 on console
adam-fanns-power-mac-g5:~ adamfann$ cd desktop
adam-fanns-power-mac-g5:desktop adamfann$ ruby phone_nums.rb
phone_nums.rb:1: syntax error, unexpected tIDENTIFIER, expecting $end
IO.foreawhen "S1if value[0,1]=="=" then value =
value[1,value.length-1].to_s ; eputs "....done." ; Unknown record
type:\n\t#{t}" ;
These are some of the lines in question from my copy of the source:
infile = "/Users/toddburch/Desktop/file.txt"
outfile = "/Users/toddburch/Desktop/file_converted.txt"
out = File.open(outfile, "w") ;
outdata = "" ;
IO.foreach(infile) {|t|
case t[0,3]
when "S01" then
if (outdata != "") then out.puts outdata end
outdata = t[15,7] ;
when "S13" then outdata += ("\t" + t[12,1].to_s) ;
when "S14" then
value = t[16,t.strip.length-2-16]
if value[0,1]=="=" then value = value[1,value.length-1].to_s ; end
outdata += "\t" + value.to_s ;
else puts "Unknown record type:\n\t#{t}" ;
end
}
He's using TextEdit to edit, and his Preferences are set for a plain
text file. He's sent me his copy after he edits it, and to the eye, it
looks fine. I have to overtype his file names to run it on my machine,
and after removing that, it works fine.
Any ideas?
Thanks, Todd (posted to Ruby Forum - I may not see your reply if you
answer is directed another list)
(By the way, the link to the FAQ is not working)
guy. It works perfect on my Mac, but not on his.
This was a quick and dirty script to reformat an ascii file. It parses
the fixed length records and writes the output in a tab delimited
format. No big deal.
I had hard coded the file name in the script, and sent it to him, to
edit and type in the correct path names for the input and output files,
and now it does not work for him.
This is the error he gets:
Last login: Sat Jun 14 16:57:06 on console
adam-fanns-power-mac-g5:~ adamfann$ cd desktop
adam-fanns-power-mac-g5:desktop adamfann$ ruby phone_nums.rb
phone_nums.rb:1: syntax error, unexpected tIDENTIFIER, expecting $end
IO.foreawhen "S1if value[0,1]=="=" then value =
value[1,value.length-1].to_s ; eputs "....done." ; Unknown record
type:\n\t#{t}" ;
These are some of the lines in question from my copy of the source:
infile = "/Users/toddburch/Desktop/file.txt"
outfile = "/Users/toddburch/Desktop/file_converted.txt"
out = File.open(outfile, "w") ;
outdata = "" ;
IO.foreach(infile) {|t|
case t[0,3]
when "S01" then
if (outdata != "") then out.puts outdata end
outdata = t[15,7] ;
when "S13" then outdata += ("\t" + t[12,1].to_s) ;
when "S14" then
value = t[16,t.strip.length-2-16]
if value[0,1]=="=" then value = value[1,value.length-1].to_s ; end
outdata += "\t" + value.to_s ;
else puts "Unknown record type:\n\t#{t}" ;
end
}
He's using TextEdit to edit, and his Preferences are set for a plain
text file. He's sent me his copy after he edits it, and to the eye, it
looks fine. I have to overtype his file names to run it on my machine,
and after removing that, it works fine.
Any ideas?
Thanks, Todd (posted to Ruby Forum - I may not see your reply if you
answer is directed another list)
(By the way, the link to the FAQ is not working)