Hello everybody,
I need to convert a Japanese Shift-JIS CSV file to Unicode UTF-8.
My machine is a Windows 98 english computer with Python 2.3.4
Any hints?. 4 8085
I think you do something like this (untested):
import codecs
def transcode(infile, outfile, incoding="shift-jis",
outcoding="utf-8"):
f = codecs.open(infile, "rb", incoding)
g = codecs.open(outfile, "wb", outcoding)
g.write(f.read())
# If the file is so large that it can't be read at once, do a loop which
# reads and writes smaller chunks
# while 1:
# block = f.read(4096000)
# if not block: break
# g.write(block)
f.close()
g.close()
Jeff
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)
iD8DBQFCjRzZJd01MZaTXX0RAg8YAJ4rQ8Fcpwi1AB2a/ZVdALGysct8jACfYdXm
in2aJ3xmdB0ncRZBWXmfMQs=
=bHjV
-----END PGP SIGNATURE-----
Hello,
I think the answer is basically correct but shift-jis is not a standard
part of
Python 2.3. You will either need to use Python 2.4 where the cjkcodes
are integrated or install them under Python 2.3. The link is http://cjkpython.i18n.org/
You then also need:
import cjkcodecs.aliases
Richard
Jeff Epler wrote: I think you do something like this (untested):
import codecs
def transcode(infile, outfile, incoding="shift-jis", outcoding="utf-8"): f = codecs.open(infile, "rb", incoding) g = codecs.open(outfile, "wb", outcoding)
g.write(f.read()) # If the file is so large that it can't be read at once, do a loop
which # reads and writes smaller chunks # while 1: # block = f.read(4096000) # if not block: break # g.write(block)
f.close() g.close()
Jeff
On Fri, May 20, 2005 at 12:16:15AM -0700, rb*****@gmx.de wrote: Hello, I think the answer is basically correct but shift-jis is not a standard part of Python 2.3.
Ah, I was fooled --- I tested on Python 2.3, but my packager must have
included the codecs you went on to mention.
Jeff
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
iD8DBQFCkcJCJd01MZaTXX0RAhNUAKCLbSsAAzxXe9UIjMXd5A N/wKcfbQCeI9j0
lpU5Zu0BgAdD2hTFvKB8kJs=
=Tof0
-----END PGP SIGNATURE----- This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Alex Stevens |
last post by:
Hi All,
I'm writing a launcher program which checks for updates and copies them down
to the client.
However, I would like the user to be able to modify the settings for the
launcher. As this...
|
by: PerryC |
last post by:
I have search googles and there are hundreds of tips about
AllowByPassKey... however, none works for me... well, perhaps I am too
new to such high level functionality that it just does not make...
|
by: maniac |
last post by:
Hey guys, I'm new here, just a simple question.
I'm learning to Program in C, and I was recommended a book called,
"Mastering C Pointers", just asking if any of you have read it,
and if it's...
|
by: Mehta Shailendrakumar |
last post by:
Hello,
Can anyone suggest me operator to perform arithmetic shift in C?
May it be for a perticular compiler.
Thank you in advance.
Regards,
Shailendra
|
by: Tim Frawley |
last post by:
I am attempting to detect a Shift+Tab in the KeyPress event for back
navigation on a control that doesn't support this method. Does anyone
have any ideas how to compare e.KeyChar to a ShiftTab?
...
|
by: Csaba Gabor |
last post by:
I'd like to detect the shift key when a button is "clicked" in
Firefox/Mozilla. If the button is clicked with the mouse, no problem.
However, if the onclick event is keyboard originated, then my...
|
by: deepak |
last post by:
If i'm shifting an integer 'n' times where n > sizeof(int), It's giving
the same value as
that of n-sizeof(n). Why is it behaving like this. I studied that the
bit 'll be replaced by '0'.
...
|
by: sandhya |
last post by:
Hello Folks,
i hava a problem in coding of circular left shift of 25 bits in my
program...how do i perform it, and how do i use unsigned in VB.
My program (IDEA algorithm implementation in VB) ...
|
by: Amy Smith |
last post by:
Hello there,
I am having a small problem which been challenging me for few days and
need help or advice.
I am trying to calculate the day-shift for employees based on the time
they started and...
|
by: Pietro |
last post by:
Hi all,
First of all I'd like to thank you very very much ,as finally after many years of searching,I could find a code to disable/enable the shift key,but actually i cannot use the code as I'm...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |