|
I am trying to automate a process (on WINDOWS OS) of manipulating a file by changing its column delimiters. I have a perl script ready but the problem i think is with the format of the file itself.
code:
#! usr/bin/perl -w
foreach (<STDIN>) {
#copy this line:
my $line = $_;
# replace every tab with ^
while ($line =~ s/"\t"/^ / ) { }
# remove double quotation marks
while ($line =~ s/"//) { }
print $line
}
sample of the input (one line of data)
[CODE]"12722" "New" "Major" "Unassigned" "Computer Manager" "Unassigned" "4.1.1" "" "library" "Bruce Borth" "Jan 7, 2008 10:27 AM" "Jan 11, 2008 1:50 PM" "Unassigned" "Library function does not have the ability to create a library without enabling it - Liraries do not depend on other lib messge missing details" "" "" "Defect"
[/CODE]
Sample output for the same line
[CODE]12722ऀ Newऀ Majorऀ Unassignedऀ Computer Managerऀ Unassignedऀ 4.1.1ऀ ऀ libraryऀ Bruce Borthऀ Jan 7, 2008 10:27 AMऀ Jan 11, 2008 1:50 PMऀ Unassignedऀ Library function does not have the ability to create a library without enabling it - Liraries do not depend on other lib messge missing detailsऀ ऀ ऀ ऀ ऀ ऀ Defectഀ
㌀㔀㐀 一攀眀 一漀爀洀愀氀 䴀攀搀椀甀洀 刀愀琀椀漀渀愀氀 䄀猀猀攀琀 䴀愀渀愀最攀爀 匀攀爀瘀攀爀 㜀⸀⸀ 㜀⸀⸀⸀ 䐀攀瘀 匀愀甀爀愀戀栀 䄀最愀爀眀愀氀 䨀愀渀 ㈀ Ⰰ ㈀ 㤀 㐀㨀㐀㔀 倀䴀 䨀愀渀 ㈀ Ⰰ ㈀ 㤀 㐀㨀㐀㘀 倀䴀 唀渀愀猀猀椀最渀攀搀 唀猀攀爀 椀猀 愀氀氀漀眀攀搀 琀漀 搀漀眀渀氀漀愀搀 琀栀攀 愀猀猀攀琀 攀瘀攀渀 琀栀漀甀最栀 椀昀 琀栀攀礀 搀漀渀琀 栀愀瘀攀 瀀攀爀洀椀猀猀椀漀渀 䐀攀昀攀挀琀 [/CODE]
The only way of making this work is if i copy the original input file into a notepad2.exe and then saving it and running the perl script on that file. The problem is i need to AUTOMATE this process.
Can anyone tell me what are these squares and why are they appearing?
|
|
|
#! usr/bin/perl -w
foreach(<STDIN>)
{
my $cline = $_;
#instead of x1:
$cline =~ s/"\t"/^ /;
#why is that spacebar there?
#the sign ^ has a meaning in perl so if u want the actual text printed just do \^.
#instead of x3:
$cline =~ s/\"//gi;
print $line
}
#x1:
#replace every tab with ^
#while ($line =~ s/"\t"/^ / ) { }
#x3:
#remove double quotation marks
#while ($line =~ s/"//) { }
|
|
|
|
|
|
|
// |