Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I specify the encoding? #11

Open
Morriaty-The-Murderer opened this issue Jun 2, 2016 · 1 comment
Open

How can I specify the encoding? #11

Morriaty-The-Murderer opened this issue Jun 2, 2016 · 1 comment

Comments

@Morriaty-The-Murderer
Copy link

Hi

My csv file contains characters (isp names) out range of ascii.
After transforming, my application could read the dat file, but result in unreadable code.

Thank you for help.

@mnicky
Copy link

mnicky commented Nov 27, 2017

It works for me with utf-8:

$ file -i GeoLiteCityv6.tst.csv
GeoLiteCityv6.tst.csv: text/plain; charset=utf-8

$ head GeoLiteCityv6.tst.csv
2001:5::,2001:5:ffff:ffff:ffff:ffff:ffff:ffff,42540488558116655331872044393019998208,42540488637344817846136381986563948543,EU,,Île-de-France,47.0000,8.0000,,0,0

$ ./csv2dat.py -w test.dat -l GeoIPCity-134euw-Location.csv mmcity6 GeoLiteCityv6.tst.csv

$ python
>>> import GeoIP
>>> r=GeoIP.open('test.dat', 0)
>>> r.record_by_addr_v6('2001:5::')
{'city': '\xc3\x8ele-de-France', 'region_name': None, 'region': None, 'area_code': 0, 'time_zone': None, 'longitude': 8.0, 'metro_code': 0, 'country_code3': 'EU', 'latitude': 47.0, 'postal_code': None, 'dma_code': 0, 'country_code': 'EU', 'country_name': 'Europe'}
>>> print r.record_by_addr_v6('2001:5::')['city'].decode('utf-8')
Île-de-France

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants