[Date Prev][Date Next][Thread Prev][Thread Next][Minivend by date
][Minivend by thread
]
Re: Fix for EXCEL data import
****** message to minivend-users from Ace Kumar <ace@digiknow.com> ******
Since I use an SQL DB (that has to be created from an Excel sheet), I
wrote this little perl program to clear up Excel's "Save as text" quirks.
NOTE:
This probably does not catch ALL of excel's quirks. It finds and
fixes all of the problems I have had with excel.
Yes, the script could have been much cleaner, but I was in a rush....
#!/usr/local/bin/perl
open(DB, "newcat17.txt");
open(OUT, ">products.asc");
while (<DB>) {
chop;
(@fields) = split(/\t/, $_);
foreach $field (@fields) {
$field =~ s/^"+//;
$field =~ s/"+$//;
$field =~ s/""+/"/g;
$field =~ s/,"|","/,/g;
push(@new, $field);
}
$tmp = join("\t", @new);
print OUT "$tmp\n";
undef(@new);
undef(@fields);
undef($field);
undef($tmp);
}
close(OUT);
close(DB);
--
Simran (Ace) Kumar, Systems Integrator - DigiKnow LLC
25700 Science Park Drive #260, Cleveland Ohio 44122
Office: (216)292-7259 Fax (216)292-4952
www.digiknow.com
-
To unsubscribe from the list, DO NOT REPLY to this message. Instead, send
email with 'UNSUBSCRIBE minivend-users' in the body to Majordomo@minivend.com.
Archive of past messages: http://www.minivend.com/minivend/minivend-list