P
Pam
Hello:
I was wondering if anyone could answer this question for me. I am
currently trying to pasre a comma sepearted file to search for empty
fields in a particluar column. I decided to parse using the
Text::CSV:XS
to check for this information since I am already parsing the text file.
The
text file loks like the one below.
"LIBkk03527","","FMOM198:JAVA MIDP
2.0_Quality_OPERATOR_5","N","2","1","", and etc.
I want to check for a ("",) in a particular column and then write
certain data to that column,
lets say column 11. The "", tell me that that field is empty, I am
already parsing the file but just to write and format it in an xls
format.
I have tried to check for empty cell such as with undef with the
paser module
I was able to find undef data but not able to do the manipulation I
needed to do, so I thought
parsing it this way would be my last hope. Can anyone help me!
This is what I am currently doing:
my $filename ='CCB.txt';
open(FILE,">$filename") || die("Cannot Open File $filename : $!" );
print FILE $query_result->content;
print "File open ";
close (FILE);
# Open the Comma Separated Variable file
open (CSVFILE, $filename) or die "$filename: $!";
# Create a new Excel workbook
my $workbook =
Spreadsheet::WriteExcel->new('3GSoftwareCCB_MeetingAgenda.xls');
my $worksheet = $workbook->add_worksheet();
my $format3 = $workbook->add_format();
$format3->set_text_wrap();
$format3->set_border();
$format3->set_bottom();
$format3->set_top();
$format3->set_left();
$format3->set_right();
# Create a new CSV parsing object
my $csv = Text::CSV_XS->new;
# Row and column are zero indexed
my $row = 0;
my $total;
my $count;
while (<CSVFILE>) {
if ($csv->parse($_)) {
my @Fld = $csv->fields;
my $col = 0;
foreach my $token (@Fld) {
$worksheet->write($row, $col, $token, $format3);
$col++;
}
$row++;
if ($row > 1){
$count = $count + 1;
$total = $count;
}
}
else {
my $err = $csv->error_input;
print "Text::CSV_XS parse() failed on argument: ", $err, "\n";
}
}
print "Adding sheet1\n";
Thanks,
Pam
I was wondering if anyone could answer this question for me. I am
currently trying to pasre a comma sepearted file to search for empty
fields in a particluar column. I decided to parse using the
Text::CSV:XS
to check for this information since I am already parsing the text file.
The
text file loks like the one below.
"LIBkk03527","","FMOM198:JAVA MIDP
2.0_Quality_OPERATOR_5","N","2","1","", and etc.
I want to check for a ("",) in a particular column and then write
certain data to that column,
lets say column 11. The "", tell me that that field is empty, I am
already parsing the file but just to write and format it in an xls
format.
I have tried to check for empty cell such as with undef with the
paser module
I was able to find undef data but not able to do the manipulation I
needed to do, so I thought
parsing it this way would be my last hope. Can anyone help me!
This is what I am currently doing:
my $filename ='CCB.txt';
open(FILE,">$filename") || die("Cannot Open File $filename : $!" );
print FILE $query_result->content;
print "File open ";
close (FILE);
# Open the Comma Separated Variable file
open (CSVFILE, $filename) or die "$filename: $!";
# Create a new Excel workbook
my $workbook =
Spreadsheet::WriteExcel->new('3GSoftwareCCB_MeetingAgenda.xls');
my $worksheet = $workbook->add_worksheet();
my $format3 = $workbook->add_format();
$format3->set_text_wrap();
$format3->set_border();
$format3->set_bottom();
$format3->set_top();
$format3->set_left();
$format3->set_right();
# Create a new CSV parsing object
my $csv = Text::CSV_XS->new;
# Row and column are zero indexed
my $row = 0;
my $total;
my $count;
while (<CSVFILE>) {
if ($csv->parse($_)) {
my @Fld = $csv->fields;
my $col = 0;
foreach my $token (@Fld) {
$worksheet->write($row, $col, $token, $format3);
$col++;
}
$row++;
if ($row > 1){
$count = $count + 1;
$total = $count;
}
}
else {
my $err = $csv->error_input;
print "Text::CSV_XS parse() failed on argument: ", $err, "\n";
}
}
print "Adding sheet1\n";
Thanks,
Pam