;examples: test files for CSV encoding [#2319]

This commit is contained in:
Simon Michael 2025-02-15 12:52:58 -10:00
parent 5114962b2a
commit cdf6ce072d
7 changed files with 33 additions and 0 deletions

View File

@ -1,3 +1,4 @@
"Date","Note","Amount"
"2012/3/22","DEPOSIT","50.00"
"2012/3/23","TRANSFER TO SAVINGS","-10.00"
"2012/3/24","COFFEE — €20 RECEIVED","-20.00"

1 Date Note Amount
2 2012/3/22 DEPOSIT 50.00
3 2012/3/23 TRANSFER TO SAVINGS -10.00
4 2012/3/24 COFFEE — €20 RECEIVED -20.00

View File

@ -0,0 +1,2 @@
include sample.csv.rules
encoding cp1252

View File

@ -0,0 +1,2 @@
include sample.csv.rules
encoding iso8859-1

View File

@ -0,0 +1,4 @@
"Date","Remarque","Montant"
"2012/3/22","DÉPÔT","50.00"
"2012/3/23","VIREMENT VERS ÉPARGNE","-10.00"
"2012/3/24","CAFÉ — €20 REÇU","-20.00"
1 Date Remarque Montant
2 2012/3/22 DÉPÔT 50.00
3 2012/3/23 VIREMENT VERS ÉPARGNE -10.00
4 2012/3/24 CAFÉ — €20 REÇU -20.00

16
examples/sample.fr.csv.py Normal file
View File

@ -0,0 +1,16 @@
text = '''"Date","Remarque","Montant"
"2012/3/22","DÉPÔT","50.00"
"2012/3/23","VIREMENT VERS ÉPARGNE","-10.00"
"2012/3/24","CAFÉ — €20 REÇU","-20.00"'''
# Create UTF-8 file
with open('sample-fr.utf8.csv', 'wb') as f:
f.write(text.encode('utf-8'))
# Create ISO-8859-1 file, replacing unsupported characters
with open('sample-fr.iso8859-1.csv', 'wb') as f:
f.write(text.encode('iso-8859-1', errors='replace'))
# Create Windows-1252 file
with open('sample-fr.cp1252.csv', 'wb') as f:
f.write(text.encode('cp1252', errors='replace'))

View File

@ -0,0 +1,4 @@
"Date","Remarque","Montant"
"2012/3/22","DÉPÔT","50.00"
"2012/3/23","VIREMENT VERS ÉPARGNE","-10.00"
"2012/3/24","CAFÉ ? ?20 REÇU","-20.00"
1 Date Remarque Montant
2 2012/3/22 DÉPÔT 50.00
3 2012/3/23 VIREMENT VERS ÉPARGNE -10.00
4 2012/3/24 CAFÉ ? ?20 REÇU -20.00

View File

@ -0,0 +1,4 @@
"Date","Remarque","Montant"
"2012/3/22","DÉPÔT","50.00"
"2012/3/23","VIREMENT VERS ÉPARGNE","-10.00"
"2012/3/24","CAFÉ — €20 REÇU","-20.00"
1 Date Remarque Montant
2 2012/3/22 DÉPÔT 50.00
3 2012/3/23 VIREMENT VERS ÉPARGNE -10.00
4 2012/3/24 CAFÉ — €20 REÇU -20.00