Oracle - Utf_file.get_line not reading utf8 csv lines properly - oracle

I have an utf8 csv file from which I want to read from.
It contains characters like ç, á, à ã...
This is what I'm doing:
CSVFile := utl_file.fopen (UPPER('dummyDIR'), CSV_name, 'r', 32767);
utl_file.get_line(CSVFile,CSVLine);
DBMS_OUTPUT.PUT_LINE('line obtained with get_line: '||CSVLine);
And all the special characters get weird...
Any idea how I can get the correct charset read?
This is what I get in Linux to check the charset:
echo $NLS_LANG
PORTUGUESE_PORTUGAL.UTF8

Related

Encoded CSV with sqlToCsv package not working with non-ASCII characters

I am using package "github.com/jeffyi/sqltocsv" to export MSSql rows to CSV files.
My problem is that special characters end up wrong way:
ü as Ć¼
ä as Ƥ
etc..
I have read the sqltocsv package multiple times and I just don't get that when and where is it going wrong.
i have logged output to console, before exporting data comes out from DB as UTF-8 but on adding to CSV it gets messed up.
I have tryed to use package "encoding/csv" to convert my data to csv file.
(without any success)
Here's how I use sqlToCsv package:
rows, _ := db.Query(sqlQuery)
csvConverter := sqltocsv.New(rows)
csvConverter.Delimiter = ';'
csvConverter.TimeFormat = time.RFC822
csvConverter.WriteFile(directory + "/" + fileName)
so in the end result should all characters be as they are:
ü as ü (not Ć¼ )
ä as ä (not Ƥ )

bpel rest adapter json output and utf-8 charcters

I have a BPEL Web Service. when I set the output type to XML , it has no problem and the utf-8 characters are working well. but when I set the output type to json, the utf-8 parts of the result goes wrong :
{
name :'ارست',
Code:12544,
Country: 'China',
Adress : 'Sian Street'
}
any suggestion to solve this problem will be appreciated.

Python 3 - GeoPy and encoding

I'm using DictWriter to write a dictionary to a csv after some geolocation work.
location = geolocator.reverse(coords)
row["address"] = location.address
writer.writerow(row)
Which generates this:
File "C:\bin64\python\3.4.3\lib\encodings\cp1252.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u200e' in
position 118: character maps to <undefined>
My problem was in how I was opening the file. I suppose I should have posted that in the question. I needed to set the encoding upon opening the file.
with open('results.csv', mode='w', encoding='utf-8', newline='') as file:
...

Ruby - CSV works while SmarteCSV doesn't

I want to open a csv file using SmarterCSV.process
market_csv = SmarterCSV.process(market)
p "just read #{market_csv}"
The problem is that the data is not read and this prints:
[]
However, if I attempt the same thing with the default CSV library implementation the content of the file is read(the following print statement prints the file).
CSV.foreach(market) do |row|
p row
end
The content of the file I was reading is of the form:
Date,Close
03/06/15,0.1634
02/06/15,0.1637
01/06/15,0.1638
31/05/15,0.1638
The problem could come from the line separator, the file is not exactly the same if you're using windows or unix system ("\r\n" or "\r"). Try to identify and specify the character in the SmarterCSV.process like this:
market_csv = SmarterCSV.process(market, row_sep: "\r")
p "just read #{market_csv}"
or like this:
market_csv = SmarterCSV.process(market, row_sep: :auto)
p "just read #{market_csv}"

Encoding german characters

I need to import with load data some perl - generated files to oracle database.
Perl-script get a webpage and write csv file.
Here a simplified script:
use File::Slurp;
my $c= ( $user && $passwd )
? get("$protocol://$user:$passwd\#$url")
: get("$protocol://$url");
write_file("$VZ_GET/$FileTS.$typ.csv",$c);
Here a sample line from the webpage:
5052;97;Jan;Ihrfelt 5053;97;Jari;Honko 5121;97;Katja;Keitaanniemi 5302;97;Ola;Södermark 5421;97;Sven;Sköld 5609;97;Peter;Näslund
Content of the webpage is saved in var $c.
Here a sample line of csv file:
5053;97;Jari;Honko
Here a load command:
LOAD DATA
INTO TABLE LIQA
TRUNCATE
FIELDS TERMINATED BY ";"
(
LIQA_ANALYST_ID,
LIQA_FIRM_ID,
LIQA_ANALYST_FIRST_NAME,
LIQA_ANALYST_LAST_NAME,
LIQA_TS_INSERT DATE 'YYYYMMDDHH24MISS'
)
Command SELECT * FROM NLS_DATABASE_PARAMETERS WHERE PARAMETER = 'NLS_CHARACTERSET'; returns AL32UTF8.
The generated csv file is recognized as UTF-8 Unicode text.
Anyhow I cant import german characters. In the csv file they are still correct. But it is not the case in the database.
I have also tried to convert $c like this:
$c = encode("iso-8859-1", $c);
The generated csv file is stll recognized as UTF-8 Unicode text.
I have no clue how can I fix it.
I have solved it:
$c = decode( 'utf-8', $c );
$c = encode( 'iso-8859-1' , $c );

Resources