Home » SQL & PL/SQL » SQL & PL/SQL » extra characters while utl_file.get_line()
extra characters while utl_file.get_line() [message #466876] Wed, 21 July 2010 10:00 Go to next message
rkhatiwala
Messages: 178
Registered: April 2007
Senior Member
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
PL/SQL Release 11.1.0.6.0 - Production
"CORE 11.1.0.6.0 Production"

hi,

i am trying to read the file, for which i m using the following:

l_utlfile_hdr := utl_file.fopen(p_dir,'header_evnt.txt', 'R');

utl_file.get_line(l_utlfile_hdr, l_hdr_evnt);

it gets these three characters at the start of the line
l_hdr_evnt = 

So i saved header_evnt.txt as UTF-8, and used utl_file.fopen_nchar,
utl_file.get_line_nchar,
which got rid of first two characters, but still has ¿. How to get rid of that?

Thank you very much.
Re: extra characters while utl_file.get_line() [message #466880 is a reply to message #466876] Wed, 21 July 2010 10:36 Go to previous messageGo to next message
Michel Cadot
Messages: 68767
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
Put the hexadecimal value of the extra-character(s) and an example of one line.

Regards
Michel
Re: extra characters while utl_file.get_line() [message #466884 is a reply to message #466880] Wed, 21 July 2010 10:49 Go to previous messageGo to next message
rkhatiwala
Messages: 178
Registered: April 2007
Senior Member
Thans Michel.

I could find in one of the EXTENDED ASCII CODES, http://www.asciitable.com/

139 ï
175 »
168 ¿

And the line output is
l_hdr_evnt = Model Year,VIN,Assembly Plant [AAG],Body Style (NA VIN based),Claim Key,Condition Code,Country Repaired,Country Sold,Customer Comments,Customer Concern Code,Document Number,Engine [EN],FCC Authorization,FCC Bin Type,Fleet / Non-Fleet,GVW Class,Labor Cost,Labor Hours,Load Date,Material Cost,Mileage,Part Num Base (Causal)

As mentioned, if i save header_evnt.txt as UTF-8, and used utl_file.fopen_nchar,
utl_file.get_line_nchar,
it will get rid of first two characters, but still has ¿.

Thank you.
Re: extra characters while utl_file.get_line() [message #466888 is a reply to message #466884] Wed, 21 July 2010 11:11 Go to previous messageGo to next message
Michel Cadot
Messages: 68767
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
No, do not have a look at a site from what you see, what you see is an interpretation and possibly conversion.
Use an hexadecimal editor and read the file directly.

Also post the content of the example line in hexadecimal (still from an hexadecimal editor).

Regards
Michel

Re: extra characters while utl_file.get_line() [message #466901 is a reply to message #466888] Wed, 21 July 2010 11:53 Go to previous messageGo to next message
rkhatiwala
Messages: 178
Registered: April 2007
Senior Member
Here is the file opened in Hex Editor:

ef bb bf 4d 6f 64 65 6c 20 59 65 61 72 2c 56 49
4e 2c 41 73 73 65 6d 62 6c 79 20 50 6c 61 6e 74
20 5b 41 41 47 5d 2c 42 6f 64 79 20 53 74 79 6c
65 20 28 4e 41 20 56 49 4e 20 62 61 73 65 64 29
2c 43 6c 61 69 6d 20 4b 65 79 2c 43 6f 6e 64 69
74 69 6f 6e 20 43 6f 64 65 2c 43 6f 75 6e 74 72
79 20 52 65 70 61 69 72 65 64 2c 43 6f 75 6e 74
72 79 20 53 6f 6c 64 2c 43 75 73 74 6f 6d 65 72
20 43 6f 6d 6d 65 6e 74 73 2c 43 75 73 74 6f 6d
65 72 20 43 6f 6e 63 65 72 6e 20 43 6f 64 65 2c
44 6f 63 75 6d 65 6e 74 20 4e 75 6d 62 65 72 2c
45 6e 67 69 6e 65 20 5b 45 4e 5d 2c 46 43 43 20
41 75 74 68 6f 72 69 7a 61 74 69 6f 6e 2c 46 43
43 20 42 69 6e 20 54 79 70 65 2c 46 6c 65 65 74
20 2f 20 4e 6f 6e 2d 46 6c 65 65 74 2c 47 56 57
20 43 6c 61 73 73 2c 4c 61 62 6f 72 20 43 6f 73
74 2c 4c 61 62 6f 72 20 48 6f 75 72 73 2c 4c 6f
61 64 20 44 61 74 65 2c 4d 61 74 65 72 69 61 6c
20 43 6f 73 74 2c 4d 69 6c 65 61 67 65 2c 50 61
72 74 20 4e 75 6d 20 42 61 73 65 20 28 43 61 75
73 61 6c 29 2c 50 61 72 74 20 4e 75 6d 20 46 75
6c 6c 20 4f 42 20 28 52 65 70 6f 72 74 65 64 29
2c 50 61 72 74 20 4e 75 6d 20 50 72 65 66 69 78
20 28 43 61 75 73 61 6c 29 2c 50 61 72 74 20 4e
75 6d 20 53 75 66 66 69 78 20 28 43 61 75 73 61
6c 29 2c 50 72 6f 64 75 63 74 69 6f 6e 20 44 61
74 65 2c 51 42 20 53 75 62 20 47 72 6f 75 70 73
2c 52 65 70 61 69 72 20 44 61 74 65 2c 52 65 70
61 69 72 20 44 65 61 6c 65 72 20 43 6f 64 65 2c
52 65 70 61 69 72 20 4d 61 69 6e 74 65 6e 61 6e
63 65 20 44 61 74 65 2c 53 65 6c 6c 20 44 65 61
6c 65 72 20 43 6f 64 65 2c 54 65 63 68 6e 69 63
69 61 6e 20 43 6f 6d 6d 65 6e 74 73 2c 54 49 53
2c 54 6f 74 61 6c 20 43 6f 73 74 20 47 72 6f 73
73 2c 54 72 61 6e 73 6d 69 73 73 69 6f 6e 20 5b
54 52 5d 2c 56 65 68 69 63 6c 65 20 4c 69 6e 65
20 41 57 53 2c 56 65 68 69 63 6c 65 20 4d 61 69
6e 74 65 6e 61 6e 63 65 20 44 61 74 65 2c 56 46
47 2c 57 61 72 72 61 6e 74 79 20 53 74 61 72 74
20 44 61 74 65 2c 57 43 43 2c 52 65 67 69 6f 6e
20 52 65 70 61 69 72 65 64 2c 52 65 67 69 6f 6e
20 53 6f 6c 64 2c 50 61 72 74 20 4e 75 6d 20 42
61 73 65 20 28 52 65 70 6f 72 74 65 64 29 2c 50
61 72 74 20 51 75 61 6e 74 69 74 79 2c 45 78 74
65 6e 64 65 64 20 41 6d 6f 75 6e 74 2c 44 54 43
20 53 65 71 75 65 6e 63 65 20 4e 75 6d 62 65 72
2c 44 54 43 20 43 6f 64 65 2c 56 4f 43 20 2f 20
45 4f 43 2c 45 43 42 20 46 6c 61 67

Model Year,VIN,Assembly Plant [AAG],Body Style (NA VIN based),Claim Key,Condition Code,Country Repaired,Country Sold,Customer Comments,Customer Concern Code,Document Number,Engine [EN],FCC Authorization,FCC Bin Type,Fleet / Non-Fleet,GVW Class,Labor Cost,Labor Hours,Load Date,Material Cost,Mileage,Part Num Base (Causal),Part Num Full OB (Reported),Part Num Prefix (Causal),Part Num Suffix (Causal),Production Date,QB Sub Groups,Repair Date,Repair Dealer Code,Repair Maintenance Date,Sell Dealer Code,Technician Comments,TIS,Total Cost Gross,Transmission [TR],Vehicle Line AWS,Vehicle Maintenance Date,VFG,Warranty Start Date,WCC,Region Repaired,Region Sold,Part Num Base (Reported),Part Quantity,Extended Amount,DTC Sequence Number,DTC Code,VOC / EOC,ECB Flag

Thanks
Re: extra characters while utl_file.get_line() [message #466910 is a reply to message #466901] Wed, 21 July 2010 12:07 Go to previous messageGo to next message
Michel Cadot
Messages: 68767
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
EF BB BF is the BOM for an UTF-8 file.
Most likely your database national character set is AL16UTF16 and not AL32UTF8, so only 2 bytes are skipped.

As it seems you do not use special characters, I advice to just read the lines and ignore the 3 first bytes.

Regards
Michel
Re: extra characters while utl_file.get_line() [message #466912 is a reply to message #466910] Wed, 21 July 2010 12:11 Go to previous messageGo to next message
rkhatiwala
Messages: 178
Registered: April 2007
Senior Member
Thanks Michel

When I opened in Hex Editor, I tried to delete the first three characters.. so now there is no special characters.. hope this works.

Thanks.
Re: extra characters while utl_file.get_line() [message #466916 is a reply to message #466912] Wed, 21 July 2010 12:15 Go to previous messageGo to next message
Michel Cadot
Messages: 68767
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
You can also ignore them when you read the file in Oracle if they are equal to a BOM.

Regards
Michel
Re: extra characters while utl_file.get_line() [message #466922 is a reply to message #466916] Wed, 21 July 2010 12:19 Go to previous messageGo to next message
rkhatiwala
Messages: 178
Registered: April 2007
Senior Member
Michel,

How can I ignore them? Like SUBSTR(.. Can you please explain.

Thanks
Re: extra characters while utl_file.get_line() [message #466926 is a reply to message #466922] Wed, 21 July 2010 12:21 Go to previous messageGo to next message
Michel Cadot
Messages: 68767
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
Yes using SUBSTR: you get the line then you use SUBSTR(...,4) into the working variable.

Regards
Michel
Re: extra characters while utl_file.get_line() [message #467711 is a reply to message #466926] Mon, 26 July 2010 17:06 Go to previous messageGo to next message
rkhatiwala
Messages: 178
Registered: April 2007
Senior Member
Hi,

Another problem:

Now I am getting this rectangle box at the end . I tried to COPY/PASTE here, but it doesn't show .
I am trying to take a printscreen, and save it as a .jpg and upload here. lets see if i can see that rectangle box.

Thanks.








/forum/fa/8089/0/
  • Attachment: 1.JPG
    (Size: 5.66KB, Downloaded 4231 times)
Re: extra characters while utl_file.get_line() [message #467712 is a reply to message #467711] Mon, 26 July 2010 17:07 Go to previous messageGo to next message
rkhatiwala
Messages: 178
Registered: April 2007
Senior Member
yes, i can see it in an image. So how to get rid of this.

Thanks.
Re: extra characters while utl_file.get_line() [message #467713 is a reply to message #467712] Mon, 26 July 2010 18:20 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
Please explain or elaborate why you are processing this file using Oracle's UTL_FILE package.
What is supposed to be done with the file content after it has been successfully processed?

It would be helpful if you followed Posting Guidelines - http://www.orafaq.com/forum/t/88153/0/
Re: extra characters while utl_file.get_line() [message #467739 is a reply to message #467711] Tue, 27 July 2010 01:07 Go to previous messageGo to next message
Michel Cadot
Messages: 68767
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
Quote:
Now I am getting this rectangle box at the end .

Post the same things as previously.

Regards
Michel
Re: extra characters while utl_file.get_line() [message #467811 is a reply to message #467739] Tue, 27 July 2010 08:46 Go to previous messageGo to next message
rkhatiwala
Messages: 178
Registered: April 2007
Senior Member
Hi,

I can see that character only if i open the filein notepad. But If i try to copy from notepad and paste here, it is not showing that last character. thats why i did the printscreen, and save in paintbrush, and upload the file here.

I am getting an data file in .xls from one of the vendors, saving it as .csv, and then using UTL_FILE, update the data to one of the tables. So first i am comparing the first line, which is the header line, to the existing header file at my end, header.txt .
This is where it is giving me these characters.. i tried to delete the header file, and recreate it by
open the data file, delete all the rows except the first one, and save it as a header.txt.
but that also didnt work. header.txt still has that extra character. i have tried to open this in hex editor, edit plus, textpad.. but only is visible in the notepad.

Thanks.
Re: extra characters while utl_file.get_line() [message #467830 is a reply to message #467811] Tue, 27 July 2010 10:27 Go to previous messageGo to next message
Michel Cadot
Messages: 68767
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
Post line in hexa, did you relaize from the whole topic this is a necessarey step?

Regards
Michel
Re: extra characters while utl_file.get_line() [message #467831 is a reply to message #467830] Tue, 27 July 2010 10:32 Go to previous messageGo to next message
rkhatiwala
Messages: 178
Registered: April 2007
Senior Member
Here you go. But that character is not visible in HEX editor.It is at the end of the line - after 'Prior Approval2'

51 42 2c 54 41 47 2c 50 41 2c 50 49 54 2c 51 42
2c 44 26 52 2c 45 6e 67 69 6e 65 65 72 2c 57 43
45 2c 53 75 70 70 6c 69 65 72 2c 57 49 2c 54 52
2c 43 68 61 72 67 65 62 61 63 6b 2c 4d 44 49 20
2d 20 44 4e 53 43 2c 44 69 73 70 2c 53 75 70 70
20 4e 61 6d 65 2c 43 6f 6d 70 6f 6e 65 6e 74 2c
49 73 73 75 65 2c 43 6f 6d 6d 65 6e 74 73 2c 52
65 76 69 65 77 65 72 2c 52 65 76 69 65 77 20 44
61 74 65 2c 4c 6f 63 61 74 69 6f 6e 2c 54 53 42
2f 53 53 4d 2c 4b 6e 6f 77 6e 2c 46 69 78 20 44
61 74 65 2c 42 53 41 51 2c 42 53 41 51 23 2c 45
4e 54 45 52 50 52 49 53 45 20 4c 4f 43 41 54 41
54 49 4f 4e 2c 47 52 49 44 20 4c 4f 43 41 54 49
4f 4e 2c 43 4f 56 45 52 20 54 59 50 45 2c 4d 44
49 3a 20 59 2f 4e 2c 44 45 46 45 43 54 20 43 69
72 63 6c 65 64 3a 20 59 2f 4e 2c 4c 65 61 74 68
65 72 20 6f 72 20 43 6c 6f 74 68 20 28 63 69 72
63 6c 65 20 31 29 2c 4c 65 61 74 68 65 72 2f 43
6c 6f 74 68 2f 56 69 6e 79 6c 20 28 63 69 72 63
6c 65 20 31 29 2c 42 55 49 4c 44 20 44 41 54 45
2c 50 72 65 66 69 78 2c 42 61 73 65 2c 53 75 66
66 69 78 2c 50 61 72 74 20 44 65 73 63 2c 4d 59
2c 56 65 68 69 63 6c 65 20 6c 69 6e 65 2c 56 49
4e 2c 4d 69 6c 65 61 67 65 2c 50 41 20 43 6f 64
65 2c 52 4f 2c 52 4f 20 44 61 74 65 2c 42 75 69
6c 64 20 44 61 74 65 2c 57 53 44 2c 43 43 43 2c
54 65 63 68 20 63 6f 6d 6d 65 6e 74 73 2c 43 75
73 74 6f 6d 65 72 20 63 6f 6d 6d 65 6e 74 73 2c
53 68 69 70 20 44 61 74 65 2c 54 61 67 20 49 73
73 75 65 20 44 61 74 65 2c 57 50 41 43 20 52 65
63 64 20 44 61 74 65 2c 50 61 72 74 20 41 6d 6f
75 6e 74 2c 4c 61 62 6f 72 20 41 6d 6f 75 6e 74
2c 52 65 70 61 69 72 20 41 6d 6f 75 6e 74 2c 53
75 70 70 6c 69 65 72 2c 52 65 71 75 65 73 74 23
2c 52 41 43 20 43 6f 64 65 2c 54 72 61 6e 73 61
63 74 69 6f 6e 20 43 6f 64 65 2c 50 72 69 6f 72
20 41 70 70 72 6f 76 61 6c 31 2c 50 72 69 6f 72
20 41 70 70 72 6f 76 61 6c 32

QB,TAG,PA,PIT,QB,D&R,Engineer,WCE,Supplier,WI,TR,Chargeback,MDI - DNSC,Disp,Supp Name,Component,Issue,Comments,Reviewer,Review Date,Location,TSB/SSM,Known,Fix Date,BSAQ,BSAQ#,ENTERPRISE LOCATATION,GRID LOCATION,COVER TYPE,MDI: Y/N,DEFECT Circled: Y/N,Leather or Cloth (circle 1),Leather/Cloth/Vinyl (circle 1),BUILD DATE,Prefix,Base,Suffix,Part Desc,MY,Vehicle line,VIN,Mileage,PA Code,RO,RO Date,Build Date,WSD,CCC,Tech comments,Customer comments,Ship Date,Tag Issue Date,WPAC Recd Date,Part Amount,Labor Amount,Repair Amount,Supplier,Request#,RAC Code,Transaction Code,Prior Approval1,Prior Approval2
Re: extra characters while utl_file.get_line() [message #467835 is a reply to message #467831] Tue, 27 July 2010 10:39 Go to previous messageGo to next message
Michel Cadot
Messages: 68767
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
Quote:
.It is at the end of the line - after 'Prior Approval2'

If it is not in the final data then what is the problem?

Regards
Michel
Re: extra characters while utl_file.get_line() [message #467839 is a reply to message #467835] Tue, 27 July 2010 11:04 Go to previous message
rkhatiwala
Messages: 178
Registered: April 2007
Senior Member
I don't see in the header.txt file, but when i compare this header line in header.txt to the header line of the data , it is showing.. and i am outputting both these in two different files, just to check the difference, that's where i found that this is the difference.
I will upload the .txt file, in which you can see that character.
And because of this character, my files don't come as identical, and the procedure quits.
Like,
if file1 = file2 then
do this.....
end if;

Thanks
Previous Topic: PRIMARY KEY
Next Topic: Basic difference between oracle 10g and oracle 11g
Goto Forum:
  


Current Time: Sun Aug 24 02:33:48 CDT 2025