[issue24787] csv.Sniffer guesses "M" instead of \t or , as the delimiter

Tiago Wright report at bugs.python.org
Sat Aug 8 00:28:39 CEST 2015


Tiago Wright added the comment:

Attached is a .py file with 32 test cases for the Sniff class, 18 that
fail, 14 that pass.

My hope is that these samples can be used to improve the delimiter
detection code.

-Tiago

----------
Added file: http://bugs.python.org/file40149/testround8.py

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue24787>
_______________________________________
-------------- next part --------------
import csv

def test_delimiters():

	delimiter_samples = [
	
		{ 'delimiter' :"\t", 'sample' :   # error:"Exception"
'''Field Name				Definition
RefID				        Unique (sequential) number assigned to vehicles
IsBadBuy				Identifies if the kicked vehicle was an avoidable purchase 
PurchDate				The Date the vehicle was Purchased at Auction
Auction					Auction provider at which the  vehicle was purchased
VehYear					The manufacturer's year of the vehicle
VehicleAge				The Years elapsed since the manufacturer's year
''' },

		{ 'delimiter' :"\t", 'sample' :   # error:"Exception"
'''rules	support	confidence	lift
1	{Brushes} => {Nail.Polish}	0.149	1	3.57142857142857
2	{Brushes} => {Bronzer}	0.097	0.651006711409396	2.33335738856414
3	{Brushes} => {Concealer}	0.092	0.61744966442953	1.39694494214826
4	{Lip.liner} => {Concealer}	0.179	0.764957264957265	1.73067254515218
5	{Bronzer} => {Concealer}	0.175	0.627240143369176	1.41909534698909
6	{Blush} => {Concealer}	0.22	0.606060606060606	1.37117784176608
''' },

		{ 'delimiter' :",", 'sample' :   # error:"Exception"
'''A,B,C,D,E
2000-01-03 00:00:00,0.980268513777,3.68573087906,-0.364216805298,-1.15973806169,foo
2000-01-04 00:00:00,1.04791624281,-0.0412318367011,-0.16181208307,0.212549316967,bar
2000-01-05 00:00:00,0.498580885705,0.731167677815,-0.537677223318,1.34627041952,baz
2000-01-06 00:00:00,1.12020151869,1.56762092543,0.00364077397681,0.67525259227,qux
2000-01-07 00:00:00,-0.487094399463,0.571454623474,-1.6116394093,0.103468562917,foo2
''' },

		{ 'delimiter' :",", 'sample' :   # error:"Exception"
'''1,699,4751,4158
8,1856
12,4059,5716,4299,4967,2128
16,1928,1176
19,1928,2775,4646,1720,3148,2552,5978,3736,3090
22,4059,1856,4103,4739,4865,4769,621,2874,1637,252
28,5321,4059,4952,1856,4103,699,1976
''' },

		{ 'delimiter' :",", 'sample' :   # error:"Exception"
'''���������Date,From,To,Flight_Number,Airline,Distance,Duration,Seat,Seat_Type,Class,Reason,Plane,Registration,Trip,Note,From_OID,To_OID,Airline_OID,Plane_OID
2004-08-27,YHZ,YYZ,,Air Canada,801,01:56,,A,Y,L,,,,,73,193,330
2004-08-01,YYZ,YHZ,,Air Canada,801,01:56,,A,Y,L,,,,,193,73,330
2004-07-30,YHZ,YYZ,,Air Canada,801,01:56,,A,Y,L,,,,,73,193,330
2004-05-30,ZRH,MUC,,Lufthansa,162,00:47,,,Y,L,,,,,1678,346,3320
2004-05-30,MUC,YYZ,,Air Canada,4131,07:53,,,Y,L,,,,,346,193,330
2004-05-30,YYZ,YOW,,Unknown,226,00:54,,,Y,L,,,,,193,100,-1
''' },

		{ 'delimiter' :"\t", 'sample' :   # error:"Exception"
'''Format version	Start date	End date	Sender	Recipient	Aggregator
5	2010-05-01	2010-05-31	Spotify	Udsvxd	Udsvxd
Country	Label	Product	Currency	Total tracks	Rightholder's tracks	Pro rata share	Revenue share	Number of users	Net revenue	Payable	USD Rate	USD Payable
XV	Ipstqx Gjivgmn	C	JFG	33126406	7	0.00	20.00	87845	851092.49	0.04	5.6647	0.09
JN	Mvcqxv Gjivgmqxd Iv	P	JFG	368037889	635611	0.01	40.00	472355	639147.36	506.62	5.6647	562.82
IL	Mvcqxv Gjivgmn	C	JFG	3501	6	0.04	20.00	8	31.61	0.05	5.6647	0.05
DW	Mvcqxv	C	DWO	62836541	58448	0.04	20.00	84344	330574.21	557.63	5.8230	513.62
''' },

		{ 'delimiter' :",", 'sample' :   # error:"Exception"
'''age,workclass,education,education-num,marital-status,occupation,relationship,race,sex,capital-gain,capital-loss,hours-per-week,native-country,1iclass
39, State-gov, 77516, Bachelors, 13, Never-married, Adm-clerical, Not-in-family, White, Male, 2174, 0, 40, United-States, <=50K
50, Self-emp-not-inc, 83311, Bachelors, 13, Married-civ-spouse, Exec-managerial, Husband, White, Male, 0, 0, 13, United-States, <=50K
38, Private, 215646, HS-grad, 9, Divorced, Handlers-cleaners, Not-in-family, White, Male, 0, 0, 40, United-States, <=50K
53, Private, 234721, 11th, 7, Married-civ-spouse, Handlers-cleaners, Husband, Black, Male, 0, 0, 40, United-States, <=50K
28, Private, 338409, Bachelors, 13, Married-civ-spouse, Prof-specialty, Wife, Black, Female, 0, 0, 40, Cuba, <=50K
37, Private, 284582, Masters, 14, Married-civ-spouse, Exec-managerial, Wife, White, Female, 0, 0, 40, United-States, <=50K
''' },

		{ 'delimiter' :"\t", 'sample' :   # error:"M"
'''Invoice File	Credit Memo	Amount Claimed	Description	Invoice	Message	
Sscanner ac15024711440.pdf	CM_15406	49213.64	MX 607293 607822 (feb)	739179	
Sscanner ac15024711441.pdf	CM 18139	15800	MX Husband	739177	
Sscanner ac15024711460.pdf	CM 18139	66399	MX Prof-specialty	739400	Photos don't match the invoice
Sscanner ac15024711481.pdf	CM_13383	1216.8	MX Exec-managerial	739406	
Sscanner ac15024711484.pdf	CM 18139	6113	MX Married-civ-spouse	739404	
Sscanner ac15024711450.pdf	CM_13383	1464.49	MX Adm-clerical	739409	
''' },

		{ 'delimiter' :",", 'sample' :   # error:"c"
'''���������Date,From,To,Flight_Number,Airline,Distance,Duration,Seat,Seat_Type,Class,Reason,Plane,Registration,Trip,Note,From_OID,To_OID,Airline_OID,Plane_OID
2009-11-22,FRA,ORD,83,American Airlines,4336,08:15,,,Y,L,,,,,340,3830,24
2009-11-21,DFW,LAX,2407,American Airlines,1233,02:42,,,Y,L,,,,,3670,3484,24
2009-11-21,ORD,FRA,84,American Airlines,4336,08:15,,,Y,L,,,,,3830,340,24
2009-11-21,LAX,ORD,1972,American Airlines,1744,03:37,,,Y,L,,,,,3484,3830,24
2009-11-04,SEA,DFW,428,American Airlines,1660,03:28,,,F,B,,,,,3577,3670,24
2009-11-02,ORD,SEA,509,American Airlines,1718,03:34,,,Y,B,,,,,3830,3577,24
''' },

		{ 'delimiter' :" ", 'sample' :   # error:"e"
'''  -7.7947021e-01   8.3822138e-01   1.0000000e+00
   1.5563491e-01   8.9537743e-01   1.0000000e+00
  -5.9907703e-02  -7.1777995e-01   1.0000000e+00
   2.0759636e-01   7.5893338e-01   1.0000000e+00
  -1.9598312e-01  -3.7548716e-01  -1.0000000e+00
   5.8848947e-01  -8.4255381e-01   1.0000000e+00
   7.1985874e-03  -5.4831650e-01  -1.0000000e+00
''' },

		{ 'delimiter' :"\t", 'sample' :   # error:"p"
'''Format version	Start date	End date	Sender	Recipient	Aggregator
8	2010-08-01	2010-08-31	Spotify	Udsvxd	Udsvxd
Country	Label	Product	URI	UPC	ISRC	Track name	Artist name	Composer name	Album name	Quantity	USD Payable
BI	Krgzur Epfrekzub Fr	Y	spotify:track:5LcJHnfHaOgzqgEdBm5SYR		BIFPH5000567	Ixev	Msp Cyhh		Ixev	582	0.57940800
UH	Krgzur Epfrekzub Fr	Y	spotify:track:5LcJHnfHaOgzqgEdBm5SYR		BIFPH5000567	Ixev	Msp Cyhh		Ixev	4	0.00464677
PT	Krgzur Epfrekzub Fr	Y	spotify:track:5LcJHnfHaOgzqgEdBm5SYR		BIFPH5000567	Ixev	Msp Cyhh		Ixev	54	0.00470712
TP	Krgzur Epfrekzub Fr	Y	spotify:track:5LcJHnfHaOgzqgEdBm5SYR		BIFPH5000567	Ixev	Msp Cyhh		Ixev	50	0.00385357
''' },

		{ 'delimiter' :"\t", 'sample' :   # error:"space"
'''Start Date	End Date	UPC	ISRC/ISBN	Vendor Identifier	Quantity	Partner Share	Extended Partner Share	Partner Share Currency	Sales or Return	Apple Identifier	Artist/Show/Developer/Author	Title	Label/Studio/Network/Developer/Publisher	Grid	Product Type Identifier	ISAN/Other Identifier	Country Of Sale	Pre-order Flag	Promo Code	Customer Price	Customer Currency
08/05/2012	09/01/2012		DXSLM1100784	DXSLM1100784	7			SHP		954411600	Cbsvas Wgrzlif	A.U.F.V.	Ugwarg Blsgbuard Sg		H5		SH				
08/05/2012	09/01/2012		DXSLM0800165	DXSLM0800165	9			SHP		188943559	Okragb Xgif	Vhl Lqkcmaylb	Ugwarg Blsgbuard Sg Mvu		H5		SH				
08/05/2012	09/01/2012		DXSLM0200696	DXSLM0200696	1			SHP		906524385	Tamu Xlcfvf	Vtg Ucrslbf (aa) [Ogr Hgjzarf Blwae]	Ugwarg Blsgbuard Sg		H5		SH				
08/05/2012	09/01/2012		DXSLM1100588	DXSLM1100588	4			SHP		989512521	Blcm Lfvcvl	Av'f Blcm	Ugwarg Blsgbuard Sg Mvu		H5		SH				
08/05/2012	09/01/2012		DXSLM0200734	DXSLM0200734_4059707501641	1			SHP		510770760	Ogzlb'f Uckdhvlb	Vhl Mcfv Mckdh	Ugwarg Blsgbuf		H5		SH				
08/05/2012	09/01/2012		DXSLM0600760	DXSLM0600760	4			SHP		767159752	Xgrral "Jbarsl" Xammi	Fg Lnlbigrl	Ugwarg Blsgbuf		H5		SH				
''' },

		{ 'delimiter' :"\t", 'sample' :   # error:"space"
'''ym	Stock Code	Artist	Title	Total)	AA)	Other)	YV)	VR)	ZF/Y2)	HB/QN)	VX/FS/MM/AN)	QB)	PR)	GX)	TN/GO)	HQ)	QG RN IK YZ)	YS)	BNW
201207	07MDI957	MXGJC BGIPTAJIGE	Leatdmxdn Utzimc	2.18	2.18	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00
201207	07MDI826	ALEE UAAIUOE	Oglmztc Ulddxdn	24.40	24.40	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00
201207	07MDI423	ALEE UAAIUOE	Jyt Elut Jyxdn	85.39	85.39	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00
201207	OIDDXT-OIIQ-BLBTG	JE006472	Sxzz Izmylu Id Oiddxt 'Bgxdat' Oxzzc Blbtgolaq Oiiq	281.18	281.18	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00
201207	MIUOLN2OZLAQ	JE006432	MIUXDI OLNNH - OZLAQ	26.67	26.67	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00
201207	MIUOQ02	PLUTE CIGQEJID	PLUTE CIGQEJID OIIQ	97.70	97.70	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00
''' },

		{ 'delimiter' :"\t", 'sample' :   # error:"space"
'''Name	Artist	Composer	Album	Grouping	Genre	Size	Time	Disc Number	Disc Count	Track Number	Track Count	Year	Date Modified	Date Added	Bit Rate	Sample Rate	Volume Adjustment	Kind	Equalizer	Comments	Plays	Last Played	Skips	Last Skipped	My Rating	Location
Csxk Sj I Biel	AQLMMLA	AQLMMLA	Zyjb Rdasb Aqxsje 2015 Btmmlbostj	Btjoibo ZYJB RDASB Msbljasje at zyjbrdasb.btr 686-669-2255	ZYJB	9887402	846			6		2015	6/87/84, 2:26 QR	6/63/84, 7:09 QR	360	22800		RQLE idkst hsml		dqolrqt qlxbdaasul kxdra oxscim hlr utn sjksl qtq xtbf ijoglrsb ijoglr labiql hxllktr alo hxll jtj-myxsb-utn ceu kixfjlaa msego bttm kxsusje alny gijk bmiqa hmy xgyogrsb admoxy bgijel qtplxhdm aoxtje sjklqljkljo lrqtplxrljo atqgsaosbiolk lkey psmk glixo b	8	4/80/84, 9:37 QR	8	3/89/84, 2:60 IR		Ribsjotag GK:Dalxa:xap:Rdasb:sOdjla:sOdjla Rdasb:AQLMMLA:Zyjb Rdasb Aqxsje 2015 Btmmlbostj:06 Csxk Sj I Biel.rq3
Bixlmlaa	Imln Psjaotj	Imln Psjaotj	Zyjb Rdasb Aqxsje 2015 Btmmlbostj	Btjoibo ZYJB RDASB Msbljasje at zyjbrdasb.btr 686-669-2255	ZYJB	80317562	641			4		2015	6/87/84, 2:26 QR	6/63/84, 7:09 QR	360	22800		RQLE idkst hsml		rskolrqt qtq xtbf kijbl hlr utn eije qixoy lrtostjim atixsje lqsb sjaqsxsje kxsusje biobgy ikuljodxtda cdsmk Afy Hlxxlsxi ijoglrsb rtosuiostjim qlxbdaasul ayjog qsijt cxsego xgyogrsb giqqy ytdoghdm qmiyhdm ljlxelosb bdol dqmshosje tqosrsaosb lnbsolk msego						Ribsjotag GK:Dalxa:xap:Rdasb:sOdjla:sOdjla Rdasb:Imln Psjaotj:Zyjb Rdasb Aqxsje 2015 Btmmlbostj:04 Bixlmlaa.rq3
Kt So Ieisj	X������yfatqq & Xtcyj				Adrrlx Wira 2014; Csmmctixk Bgixolk - DF; Ieisj	86647541	309			3		2014	4/61/82, 5:65 QR	9/9/84, 7:29 QR	360	22800		RQLE idkst hsml								Ribsjotag GK:Dalxa:xap:Rdasb:sOdjla:sOdjla Rdasb:X������yfatqq & Xtcyj:Djfjtpj Imcdr:03 Kt So Ieisj.rq3
Hsjk Ry Piy Msrsolx	Gdobg Gixxsa		Oicml 45			64370600	838						86/4/82, 9:07 QR	86/4/82, 9:07 QR	8439	25000		PIU idkst hsml			6	9/9/84, 7:61 QR				Ribsjotag GK:Dalxa:xap:Rdasb:sOdjla:sOdjla Rdasb:Gdobg Gixxsa:Oicml 45:Hsjk Ry Piy Msrsolx.piu
Esul So 6 Rl	Riktjji		Gixk Bijky		Qtq	9505711	657			3	86	2008	2/6/84, 80:06 IR	2/6/84, 80:09 IR	851	22800		RQLE idkst hsml								Ribsjotag GK:Dalxa:xap:Rdasb:sOdjla:sOdjla Rdasb:Riktjji:Gixk Bijky:03 Esul So 6 Rl.rq3
S Wdao Pijji Mtul D (Esul So 6 Rl)	Wiy-Z	Bgxsaotqglx Pimmibl/Fsoo Pimflx/Rsfl Hmtplxa/Alij Btrca/Klxsb Rsbgilm "KTQ" Ijelmloosl/Otkk Agip/Qgixxlmm Psmmsira/Bgik Gdet/Wirla Wtgjatj/Agipj Bixolx	Ogl Kyjiaoy Xtb Mi Hirsmsi 2000		Xiq	9120192	667	8	8	3	89	2000	2/6/84, 80:06 IR	2/6/84, 80:09 IR	360	22800		RQLE idkst hsml								Ribsjotag GK:Dalxa:xap:Rdasb:sOdjla:sOdjla Rdasb:Btrqsmiostja:Ogl Kyjiaoy Xtb Mi Hirsmsi 2000:03 S Wdao Pijji Mtul D (Esul So 6 Rl).rq3
''' },

		{ 'delimiter' :"\t", 'sample' :   # error:","
'''01-12-2010	31-12-2010	BPRDO0508860	Slrekr Mqftdwn	Ejd Zkdc Vlqm Ejd Svedlfqqf	Cjsedzdl Adqaod Nsw K Sm, Ejse'n Cjse K'm Fqe	5034202016250	VL	4	0.0418
01-12-2010	31-12-2010	BPRDO0508868	Slrekr Mqftdwn	K Pde Wqy Oqqt Bqqh Qf Ejd Hsfrdvoqql	Cjsedzdl Adqaod Nsw K Sm, Ejse'n Cjse K'm Fqe	5034202016250	VL	1	0.0162
01-12-2010	31-12-2010	BPRDO0508864	Slrekr Mqftdwn	Vstd Esodn Qv Nsf Vlsfrknrq	Cjsedzdl Adqaod Nsw K Sm, Ejse'n Cjse K'm Fqe	5034202016250	VL	8	0.0848
01-12-2010	31-12-2010	BPRDO0508862	Slrekr Mqftdwn	Hsfrkfb Njqdn	Cjsedzdl Adqaod Nsw K Sm, Ejse'n Cjse K'm Fqe	5034202016250	VL	8	0.0848
01-12-2010	31-12-2010	BPRDO0508867	Slrekr Mqftdwn	Lkqe Zsf	Cjsedzdl Adqaod Nsw K Sm, Ejse'n Cjse K'm Fqe	5034202016250	VL	4	0.0418
01-12-2010	31-12-2010	BPRDO0508869	Slrekr Mqftdwn	Ldh Okbje Kfhkrsedn Hqqln Sld Ndryldh	Cjsedzdl Adqaod Nsw K Sm, Ejse'n Cjse K'm Fqe	5034202016250	VL	4	0.0418
01-12-2010	31-12-2010	BPRDO0508866	Slrekr Mqftdwn	Mslhw Pym	Cjsedzdl Adqaod Nsw K Sm, Ejse'n Cjse K'm Fqe	5034202016250	VL	8	0.0848
''' },

		{ 'delimiter' :"\t", 'sample' :   # error:":"
'''Format version	Start date	End date	Sender	Recipient	Aggregator
1	09/01/11	09/30/11	Spotify	Udsvxd	Udsvxd
Country	Label	Product	URI	UPC	EAN	ISRC	Track name	Artist name	Composer name	Album name	Quantity	USD Payable
VR	Jthrxt Psftpjrxk Ft	H	spotify:track:02xTp9FM6wiKSFB0B55vze		5036202029354	{'isrc': 'KDFSL1000399'}	Hqpoqx	Woqcc, Qcahtx, Bcseusx		Vtp Cus Kutbcb Wrcurx	1	0.0113
BS	Jthrxt Psftpjrxk Ft	H	spotify:track:02xTp9FM6wiKSFB0B55vze		5036202029354	{'isrc': 'KDFSL1000399'}	Hqpoqx	Woqcc, Qcahtx, Bcseusx		Vtp Cus Kutbcb Wrcurx	4	0.0715
XL	Jthrxt Psftpjrxk Ft	Q	spotify:track:02xTp9FM6wiKSFB0B55vze		5036202029354	{'isrc': 'KDFSL1000399'}	Hqpoqx	Woqcc, Qcahtx, Bcseusx		Vtp Cus Kutbcb Wrcurx	1	0.0038
SB	Jthrxt Psftpjrxk Ft	H	spotify:track:02xTp9FM6wiKSFB0B55vze		5036202029354	{'isrc': 'KDFSL1000399'}	Hqpoqx	Woqcc, Qcahtx, Bcseusx		Vtp Cus Kutbcb Wrcurx	1	0.0060
''' },

		{ 'delimiter' :"\t", 'sample' :   # error:"Exception"
'''Format version	Start date	End date	Recipient	Aggregator
2	11/01/11	11/30/11	Udsvxd	Udsvxd
Country	Label	Product	Currency	Total tracks	Rightholder's tracks	Pro rata share	Revenue share	Subscriber number	Net revenue	Payable	EUR Payable	USD Payable
QG	Spnxlp Hgyphsi	M	JIS	959	3	0.93	90	3	37.9397	0.0451	0.0517	0.0451
QG	Spjafg Ixk Hgyphsi	M	JIS	959	3	0.93	90	3	37.9397	0.0451	0.0517	0.0451
QZ	Spnxlp	J	GJH	10702	77	0.09	90	11	294.4235	0.0550	0.0550	0.0444
QZ	Spnxlp Hgyphsxld Yp	J	GJH	10702	43	0.72	90	11	294.4235	0.7180	0.7180	0.3392
''' },

		{ 'delimiter' :"\t", 'sample' :   # error:"Exception"
'''Format version	Start date	End date	Sender	Recipient	Aggregator
5	11/01/11	11/30/11	Spotify	Udsvxd	Udsvxd
Country	Label	Product	URI	UPC	EAN	ISRC	Track name	Artist name	Composer name	Album name	Quantity	USD Payable
CW	Lsmwts Onysolz	500	spotify:track:1EpGeaPY1xl7AKDwTA5ICI	6081303033068	6081303033068	UDYNP0900112	Hsvwst Qhhosqyjwtu	Qoyvwy Mstfnkz		Jemdeu	5	0.1913
ZN	Lsmwts Onysolz	10	spotify:track:1EpGeaPY1xl7AKDwTA5ICI	6081303033068	6081303033068	UDYNP0900112	Hsvwst Qhhosqyjwtu	Qoyvwy Mstfnkz		Jemdeu	5	0.2430
UD	Lsmwts Onysolz	50	spotify:track:1EpGeaPY1xl7AKDwTA5ICI	6081303033068	6081303033068	UDYNP0900112	Hsvwst Qhhosqyjwtu	Qoyvwy Mstfnkz		Jemdeu	5	0.7039
CO	Lsmwts Onysolwtu Ys	10	spotify:track:3XcGI3U2oubSZ81biq57b9		6081303032065	UDYNP5000448	Wpp Dn Kseo Mqt	Qttq Yqpgw		Qttq Yqpgw	5	0.2283
''' },

		{ 'delimiter' : "\t", 'sample' :  # success: "\t"
'''01-12-2011	31-12-2011	PRLXA0300433	Denz Qxq	Hwpxa Xljexo	Qjxzx Bo Aemx Bw Ven	6095707076560	PR	9	0.0401
01-12-2011	31-12-2011	PRLXA0300808	Denz Qxq	Ojx Inoq Abyxo Qe Dbpjq	Qjxzx Bo Aemx Bw Ven	6095707076560	PR	8	0.2521
01-12-2011	31-12-2011	PRLXA0300800	Denz Qxq	Aemx Lzv	Qjxzx Bo Aemx Bw Ven	6095707076560	PR	9	0.0401
01-12-2011	31-12-2011	PRLXA0300809	Denz Qxq	Obwp	Qjxzx Bo Aemx Bw Ven	6095707076560	PR	5	0.012
01-12-2011	31-12-2011	PRLXA0300802	Denz Qxq	Lbzlabwp	Qjxzx Bo Aemx Bw Ven	6095707076560	PR	9	0.0401
01-12-2011	31-12-2011	PRLXA0300805	Denz Qxq	Qjbo Nwdeaso	Qjxzx Bo Aemx Bw Ven	6095707076560	PR	5	0.012
01-12-2011	31-12-2011	PRLXA2200759	Raees Ezhwpx	Onqujbw Renaxmhzs	Onqujbw Renaxmhzs	6095707257061	PR	24	0.975
''' },

		{ 'delimiter' : "\t", 'sample' :  # success: "\t"
'''Start Date	End Date	UPC	ISRC/ISBN	Vendor Identifier	Quantity	Partner Share	Extended Partner Share	Partner Share Currency	Sales or Return	Apple Identifier	Artist/Show/Developer/Author	Title	Label/Studio/Network/Developer/Publisher	Grid	Product Type Identifier	ISAN/Other Identifier	Country Of Sale	Pre-order Flag	Promo Code	Customer Price	Customer Currency
05/06/2012	06/02/2012		KIUDS0400639	KIUDS0400639	5	0.002240662	0.002240662	EOB		403440397	Usfzfu	Cwsovwcc	Byafzy Pduypbo		N4		IP				
05/06/2012	06/02/2012		KIUDS0900070	KIUDS0900070	6	0.002240662	0.05508092	EOB		689702292	Vnd Awkzdvfu Cfdsbo	Sdv'o Jpdvdzdb Qd'pd Iezzl Pwiifvo	Byafzy Pduypbo		N4		WP				
05/06/2012	06/02/2012		KIUDS0800513	KIUDS0800513	5	0.002240662	0.002240662	EOB		621009036	Hezfyp Iylo	Uweknv Fz w Qwtd	Byafzy Pduypbo		N4		IP				
05/06/2012	06/02/2012		KIUDS0100859	KIUDS0100859	5	0.002240662	0.002240662	EOB		636890988	Pyidpv Qlwvv	Sfvvsd Pdb Pyifz Nyyb Nfv vnd Pywb	Byafzy Pduypbo		N4		WP				
05/06/2012	06/02/2012		KIUDS0200146	KIUDS0200146	54	0.002240662	0.075136362	EOB		10370786	Cpwzr Cdpbfzwzb	Dsdwzyp Jev Lyep Iyyvo Yz	Byafzy Pduypbfzk Uy Svb		N4		US				
05/06/2012	06/02/2012		KIUDS0800574	KIUDS0800574	5	0.002240662	0.002240662	EOB		542377384	Wpuvfu Ayzgdlo	Qny vnd Ceug Wpd Wpuvfu Ayzgdlo?	Byafzy Pduypbfzk Uy Svb		N4		JD				
''' },

		{ 'delimiter' : "\t", 'sample' :  # success: "\t"
'''DSN	Actual Ship Date	Carrier Name	SCAC	Carrier Route Reference	Tracking Number	SSCC	Warehouse Short Name	RETAILER NAME	Purchase Order Id	Sales Order Id	ITEM NAME	PRODUCT CODE NAME	ASIN	UPC	Reseller Item Code
50867707487408X3	2015-07-31	DABBJDI DXCCEJC	DDDD	02275851086558021		002275859971801442	LQ-EPBRQI	Etidapjs, Etd	716427	QAIMHETQAN.8	Hetai 3MF, YeWE, OH64QOE, CAY/JL/DX/PS/FC/NX, ATBETJ/AWWBETJ	Hetai	F00RM1MFOP	131685037747	IX000KOB09
5086770748740ZS2	2015-07-31	DABBJDI DXCCEJC	DDDD	02275851086558021		002275859971801442	LQ-EPBRQI	Etidapjs, Etd	716427	QAIMHETQAN.8	Hetai 3MF, YeWE, OH64QOE, CAY/JL/DX/PS/FC/NX, ATBETJ/AWWBETJ	Hetai	F00RM1MFOP	131685037747	IX000KOB09
5086770748740R0Z	2015-07-31	DABBJDI DXCCEJC	DDDD	02275851086558021		002275859971801442	LQ-EPBRQI	Etidapjs, Etd	716427	QAIMHETQAN.8	Hetai 3MF, YeWE, OH64QOE, CAY/JL/DX/PS/FC/NX, ATBETJ/AWWBETJ	Hetai	F00RM1MFOP	131685037747	IX000KOB09
5086770748740R8W	2015-07-31	DABBJDI DXCCEJC	DDDD	02275851086558021		002275859971801442	LQ-EPBRQI	Etidapjs, Etd	716427	QAIMHETQAN.8	Hetai 3MF, YeWE, OH64QOE, CAY/JL/DX/PS/FC/NX, ATBETJ/AWWBETJ	Hetai	F00RM1MFOP	131685037747	IX000KOB09
5086770748740B0O	2015-07-31	DABBJDI DXCCEJC	DDDD	02275851086558021		002275859971801442	LQ-EPBRQI	Etidapjs, Etd	716427	QAIMHETQAN.8	Hetai 3MF, YeWE, OH64QOE, CAY/JL/DX/PS/FC/NX, ATBETJ/AWWBETJ	Hetai	F00RM1MFOP	131685037747	IX000KOB09
5086770748740B90	2015-07-31	DABBJDI DXCCEJC	DDDD	02275851086558021		002275859971801442	LQ-EPBRQI	Etidapjs, Etd	716427	QAIMHETQAN.8	Hetai 3MF, YeWE, OH64QOE, CAY/JL/DX/PS/FC/NX, ATBETJ/AWWBETJ	Hetai	F00RM1MFOP	131685037747	IX000KOB09
''' },

		{ 'delimiter' : "\t", 'sample' :  # success: "\t"
'''Product Context	Product Attribute	Product Value	Product Description	UOM	Primary UOM	Line Type	Price Break Type	Application Method	Value	Static Formula	Start Date	End Date	Precedence	[ ]	
Rpwt	Rpwt Oftdwh	D008N0QKYW	Lrogqw Nrhw Yqwwew	WM		Uhriw Qryp Qrow		Forp Uhriw	35.55			73-TMH-2012	330		
Rpwt	Rpwt Oftdwh	D008N0QKYW	Lrogqw Nrhw Yqwwew	WM		Uhriw Qryp Qrow		Forp Uhriw	32.55		74-TMH-2012		330		
Rpwt	Rpwt Oftdwh	D008NH35BT	Lrogqw Nrhw Gwtj - FY	WM		Uhriw Qryp Qrow		Forp Uhriw	725				330		
Rpwt	Rpwt Oftdwh	D008N0QKGA	Lrogqw Pjfik Qwmpkwh Ijewh	WM		Uhriw Qryp Qrow		Forp Uhriw	45.55				330		
Rpwt	Rpwt Oftdwh	D002YG348M	Lrogqw Pjfik Qrskpwg Qwmpkwh Ijewh	WM		Uhriw Qryp Qrow		Forp Uhriw	85.55				330		
Rpwt	Rpwt Oftdwh	D008NH3MDM	Lrogqw Pjfik 4S Gwtj - FY	WM		Uhriw Qryp Qrow		Forp Uhriw	50				330		
''' },

		{ 'delimiter' : "\t", 'sample' :  # success: "\t"
'''Modifier No	Level	Modifier Type	Start Date	End Date	Print On Invoice	Automatic	Override	Pricing Phase	Incompatibility Group	Bucket	Proration Type	Comparison Value	Product Attribute	Product Attribute Value	Product Description	Volume Type	Break Type	Operator	UOM	Value From	Value To	[ ]	Charge Name	Include On Returns	Formula	Application Method	Value	Benefit Quantity	Benefit UOM	Expiration Date	Expiration Period Start Date	Expiration Period	Period Type	Rebate Transaction Type	Accrual Redemption Rate	Accrual Conversion Rate	Upgrade Item	Terms Attribute	Terms Value	Benefit Quantity	Benefit UOM	Redemption Rate	Coupon Conversion Rate	Expiration Date	Expiration Start Date	Expiration Period	Expiration Period Type	Coupon Modifier Number	Adjustment Type	Net Amount Calculation	Expiration Date	Expiration Start Date	Expiration Duration	Period Type	Rebate Transaction Type	Accrual Redemption Rate	
F0014L12EM	Uabp	Tamjnkbz			*	*	*	Uamz Uabp Rtdkmzepbz	Upipu 6 Abjneyrzafauazs	6	Bnbp		Azpe Bkefph	F0014L12EM	Wabtup Cahp OT 7" 63XF - HNV				PR							Bpv Yhajp	806																														
F003LLM5GG	Uabp	Tamjnkbz			*	*	*	Uamz Uabp Rtdkmzepbz	Upipu 6 Abjneyrzafauazs	6	Bnbp		Azpe Bkefph	F003LLM5GG	Wabtup Va-Ca 3" P-Abw				PR							Bpv Yhajp	12																														
F007EA8CKG	Uabp	Tamjnkbz			*	*	*	Uamz Uabp Rtdkmzepbz	Upipu 6 Abjneyrzafauazs	6	Bnbp		Azpe Bkefph	F007EA8CKG	Jpupmzp Va-Ca, HNV/PK				PR							Bpv Yhajp	656																														
''' },

		{ 'delimiter' : ",", 'sample' :  # success: ","
'''Name,Given Name,Additional Name,Family Name,Yomi Name,Given Name Yomi,Additional Name Yomi,Family Name Yomi,Name Prefix,Name Suffix,Initials,Nickname,Short Name,Maiden Name,Birthday,Gender,Location,Billing Information,Directory Server,Mileage,Occupation,Hobby,Sensitivity,Priority,Subject,Notes,Group Membership,E-mail 1 - Type,E-mail 1 - Value,E-mail 2 - Type,E-mail 2 - Value,E-mail 3 - Type,E-mail 3 - Value,E-mail 4 - Type,E-mail 4 - Value,Phone 1 - Type,Phone 1 - Value,Phone 2 - Type,Phone 2 - Value,Phone 3 - Type,Phone 3 - Value,Address 1 - Type,Address 1 - Formatted,Address 1 - Street,Address 1 - City,Address 1 - PO Box,Address 1 - Region,Address 1 - Postal Code,Address 1 - Country,Address 1 - Extended Address,Address 2 - Type,Address 2 - Formatted,Address 2 - Street,Address 2 - City,Address 2 - PO Box,Address 2 - Region,Address 2 - Postal Code,Address 2 - Country,Address 2 - Extended Address,Address 3 - Type,Address 3 - Formatted,Address 3 - Street,Address 3 - City,Address 3 - PO Box,Address 3 - Region,Address 3 - Postal Code,Address 3 - Country,Address 3 - Extended Address,Organization 1 - Type,Organization 1 - Name,Organization 1 - Yomi Name,Organization 1 - Title,Organization 1 - Department,Organization 1 - Symbol,Organization 1 - Location,Organization 1 - Job Description,Website 1 - Type,Website 1 - Value,Website 2 - Type,Website 2 - Value
Woydwyu Ltai Pixxwft,Woydwyu Ltai,,Pixxwft,,,,,,,,,,,,,,,,,,"Cooking, Biking, Yoga",,,,"Program: MBA
Country: Philippines
City: San Fernando Pampanga
Relationship Status: In a Relationship
Address in Boston: 217 Pjapmk Hzrooz (Phiylwm), #1552A, Tpuarqyno
Area of Focus: Healthcare/Biotech
''' },

		{ 'delimiter' : ",", 'sample' :  # success: ","
'''���������Poqz,EffectiveDate,ExpiryDate,ExternalSku
Y005SQTCAN,30-Ivt-2014,01-Ivt-2017,100
Y00LSBCUYE,24-Tax-14,,UE000LSH01
Y00IM8MYSP,24-Tax-14,,UE000LSH03
Y00LBP8HK8,24-Tax-14,,EW00LSH03
Y008YESU4L,24-Tax-14,,EW00LSH08
Y006MZA624,24-Tax-14,,EW001LSH01
''' },

		{ 'delimiter' : ",", 'sample' :  # success: ","
'''Amazon DE MP3 Sales (Cost in Euros),,,,,,,,,,,,
01/01/2010 - 01/31/2010,,,,,,,,,,,,
"Amazon EU S������rl (AEU) is based in Luxembourg and issues payments automatically.������ Unless you are established in Luxembourg and will charge us Luxembourg VAT we do not need to receive a VAT invoice from you before we can make payment . ������������AEU���������s ������address is Amazon EU S������rl, 5, Rue Plaetis, L-2338 Luxembourg.������ VAT registration number is LU 20260743",,,,,,,,,,,,
ASIN,ALBUM_ID,RELATED_UPC,Track_ID,ISRC,ALBUM_TRACK,Units,COST,Amount_Due,ALBUM_ARTIST,ALBUM_NAME,Track_Name,LABEL_NAME
Y003S6BUB3,5096303033059,5096303033059,,,V,20,8.1,632.00,"Vfnjhn Zdisupq","Tczxcy","","Wdzhid Fundfwq"
K003P6NGYH,5096303033059,5096303033059,YX-NUA-07-00663,YX-NUA-07-00663,J,8,.88,9.78,"Vfnjhn Zdisupq","Tczxcy","Zp Bfdbuaauf","Wdzhid Fundfwq"
Q003P6FEC3,5096303033059,5096303033059,YX-NUA-07-00662,YX-NUA-07-00662,J,6,.88,3.86,"Vfnjhn Zdisupq","Tczxcy","Ehfu Viw Jtu Jtcw","Wdzhid Fundfwq"
''' },

		{ 'delimiter' : ",", 'sample' :  # success: ","
'''artist_name,album_name,album_id
Ntijin,3GXh,2438
"Upg Cdzjguin Vigtbh","69 Taqg Hajzh",2439
"Xgdwijz Tizpuh",936,2440
"Xgdwijz Tizpuh","936 (Hxgnidt Eajoh Gbiuiaj)",2441
Ugtg:vojwgj,"D Nattgnuiaj Av Ing-Nsgdc Qdjh",2442
"Tdosd Cdstijz","D Nsgduosg I Baj'u Wjak",2443
''' },

		{ 'delimiter' : " ", 'sample' :  # success: " "
'''   6.0000000e+00   3.4109180e-01  -4.5289375e+00
   5.0000000e+00   4.4413086e-01  -5.4968125e+00
   4.0000000e+00   2.3100195e-01  -2.8867500e+00
   7.0000000e+00   2.0027539e-01  -3.5343750e+00
   3.0000000e+00   2.9193555e-01  -4.3520625e+00
   6.0000000e+00   2.1278516e-01  -3.7213750e+00
   3.0000000e+00   2.0337891e-01  -3.3363125e+00
''' },

		{ 'delimiter' : "|", 'sample' :  # success: "|"
'''Transmissionno|"Start_Date"|"End_Date"|"Service_provider_country"|"Consumer_country_code"|"ISRC"|"UPC"|"Digital_offering_id"|"Product_type"|Quantity|"Royalty_currency"|Wholesale_price|Wholesale_value|"PaymentCurrency"|WholesalevaluePC|"Artist_name"|"Album_name"|"Track_name"|"Commitment_type"
273536|"20110801"|"20110831"|"JP"|"JP"|""|"7035808080775"|""|"CHPRZ YVMONT"|90|"JPW"|9.34186226|93.41862260|"RAO"|88.361899590000009|"Bvcgl Bmvongcgo"|"Txgnjdt"|""|"Adxvt-Tmvz-98 Yxzzntzmgt"
273536|"20110801"|"20110831"|"JP"|"JP"|""|"7035808085674"|""|"CHPRZ YVMONT"|90|"JPW"|9.34186226|93.41862260|"RAO"|88.361899590000009|"Tdm Unhha"|"Phxxo Wvmaarvma"|""|"Adxvt-Tmvz-98 Yxzzntzmgt"
273536|"20110801"|"20110831"|"JP"|"JP"|""|"7035808087472"|""|"CHPRZ YVMONT"|939|"JPW"|9.54170080|965.42878280|"RAO"|395.76740759666664|"Cvytny Zxgumsa"|"Aryu Nt cgo Amm"|""|"Hxgj-Tmvz Yxzzntzmgt"
273536|"20110801"|"20110831"|"JP"|"JP"|""|"7035808087472"|""|"CHPRZ YVMONT"|90|"JPW"|9.64460230|96.44602300|"RAO"|38.906461120000003|"Cvytny Zxgumsa"|"Aryu Nt cgo Amm"|""|"Adxvt-Tmvz Yxzzntzmgt"
273536|"20110801"|"20110831"|"JP"|"JP"|""|"7035808087472"|""|"CHPRZ YVMONT"|18|"JPW"|9.34186226|66.44732924|"RAO"|929.87668892|"Cvytny Zxgumsa"|"Aryu Nt cgo Amm"|""|"Adxvt-Tmvz-98 Yxzzntzmgt"
273536|"20110801"|"20110831"|"JP"|"JP"|""|"7035808082079"|""|"CHPRZ YVMONT"|95|"JPW"|9.54170080|80.48700840|"RAO"|33.280687126666666|"Cggc Ychin"|"Cggc Ychin"|""|"Hxgj-Tmvz Yxzzntzmgt"
''' },

		{ 'delimiter' : "|", 'sample' :  # success: "|"
'''Transmissionno|"Start_Date"|"End_Date"|"Service_provider_country"|"Consumer_country_code"|"ISRC"|"UPC"|"Digital_offering_id"|"Product_type"|Quantity|"Royalty_currency"|Wholesale_price|Wholesale_value|"PaymentCurrency"|WholesalevaluePC|"Artist_name"|"Album_name"|"Track_name"|"Commitment_type"
Transmission_#|"Start_Date"|"End_Date"|"Service_provider_country"|"usage_type"|"ISRC"|"UPC"|"Activity_type"|quantity|"royalty_currency"|royalty_price_LC|royalty_amount_lc|"payment_currency"|royalty_amount_pc|"artist_name"|"album_name"|"track_name"|"Commitment_type"
Transmission_#|"Start_Date"|"End_Date"|"Service_provider_country"|"usage_type"|"ISRC"|"UPC"|"Activity_type"|quantity|"royalty_currency"|royalty_price_LC|royalty_amount_lc|"payment_currency"|royalty_amount_pc|"artist_name"|"album_name"|"track_name"|"Commitment_type"
Transmissionno|"Start_Date"|"End_Date"|"Service_provider_country"|"Consumer_country_code"|"ISRC"|"UPC"|"Digital_offering_id"|"Product_type"|Quantity|"Royalty_currency"|Wholesale_price|Wholesale_value|"PaymentCurrency"|WholesalevaluePC|"Artist_name"|"Album_name"|"Track_name"|"Commitment_type"
Transmission_#|"Start_Date"|"End_Date"|"Service_provider_country"|"usage_type"|"ISRC"|"UPC"|"Activity_type"|quantity|"royalty_currency"|royalty_price_LC|royalty_amount_lc|"payment_currency"|royalty_amount_pc|"artist_name"|"album_name"|"track_name"|"Commitment_type"
Transmission_#|"Start_Date"|"End_Date"|"Service_provider_country"|"usage_type"|"ISRC"|"UPC"|"Activity_type"|quantity|"royalty_currency"|royalty_price_LC|royalty_amount_lc|"payment_currency"|royalty_amount_pc|"artist_name"|"album_name"|"track_name"|"Commitment_type"
Transmissionno|"Start_Date"|"End_Date"|"Service_provider_country"|"Consumer_country_code"|"ISRC"|"UPC"|"Digital_offering_id"|"Product_type"|Quantity|"Royalty_currency"|Wholesale_price|Wholesale_value|"PaymentCurrency"|WholesalevaluePC|"Artist_name"|"Album_name"|"Track_name"|"Commitment_type"
''' },

		{ 'delimiter' : "|", 'sample' :  # success: "|"
'''Transmission_#|"Start_Date"|"End_Date"|"Service_provider_country"|"usage_type"|"ISRC"|"UPC"|"Activity_type"|quantity|"royalty_currency"|royalty_price_LC|royalty_amount_lc|"payment_currency"|royalty_amount_pc|"artist_name"|"album_name"|"track_name"|"Commitment_type"
598775|"20110701"|"20110731"|"EB"|"VOE"|"EBCIP1100059"|"9043808085896"|"Cpgivo Mpjnh"|84|"EBM"|.01821272|.86324163|"QHL"|.37236695|"Rqvgxs Bxnh"|"Go'h Jpp Osqi"|"Goctn Dgveish"|""
598775|"20110701"|"20110731"|"EB"|"VOE"|"EBCIP0900286"|"9043808181943"|"Liwgci Mpjnh"|4|"EBM"|.01821272|.04239543|"QHL"|.05831866|"Dsjva Dislgvjvl"|"Fjpk Jfjn"|"Fjpk Jfjn"|""
598775|"20110701"|"20110731"|"LI"|"MSIYGQY"|"EBCIP1100012"|"9043808131995"|"Hosijy"|1|"IQS"|.01034151|.01034151|"QHL"|.01366514|"Jbxqo Esxqm"|"Lxv'o Fxssn"|"Lxv'o Fxssn"|""
598775|"20110701"|"20110731"|"LI"|"VOE"|"EBCIP0901172"|"5034202016656"|"Cpgivo Mpjnh"|1|"IQS"|.01026032|.01026032|"QHL"|.01959972|"Oipiwghgxv Mishxvjpgogih"|"Yn Ljsk Mpjcih"|"Vx Yxsi G Tjoi Nxqh"|""
598775|"20110701"|"20110731"|"LI"|"MSIYGQY"|"EBCIP1000756"|"9043808085091"|"Cpgivo Mpjnh"|182|"IQS"|.01034151|1.44983502|"QHL"|1.61690347|"Jvvj Cjpwg"|"Jvvj Cjpwg"|"Hqajvvi Jvl G"|""
598775|"20110701"|"20110731"|"EB"|"VOE"|"EBCIP0200485"|"5034202019558"|"Liwgci Mpjnh"|1|"EBM"|.01821272|.01821272|"QHL"|.08020344|"Osgckn"|"Kvxfpi Fiho Bxn"|"Bjcjogwi"|""
''' },

		{ 'delimiter' :"\t", 'sample' :
'''a	b	c
1	2	3
4	5	6''' }
	]
	
	for sample in delimiter_samples:
		sniffer = csv.Sniffer()
		try:
			dialect = sniffer.sniff(sample["sample"])
			print("%s: Expected %s got %s" % ( sample["delimiter"] == dialect.delimiter, repr(sample["delimiter"]), repr(dialect.delimiter)))
		except:
			print(r"False: Expected %s got Exception" % repr(sample["delimiter"]))



"""
False: Expected '\t' got Exception
False: Expected '\t' got Exception
False: Expected ',' got Exception
False: Expected ',' got Exception
False: Expected ',' got Exception
False: Expected '\t' got Exception
False: Expected ',' got Exception
False: Expected '\t' got Exception
False: Expected ',' got 'c'
False: Expected ' ' got 'e'
False: Expected '\t' got Exception
False: Expected '\t' got ' '
False: Expected '\t' got ' '
False: Expected '\t' got ' '
False: Expected '\t' got ','
False: Expected '\t' got ':'
False: Expected '\t' got Exception
False: Expected '\t' got Exception
True: Expected '\t' got '\t'
True: Expected '\t' got '\t'
True: Expected '\t' got '\t'
True: Expected '\t' got '\t'
True: Expected '\t' got '\t'
True: Expected ',' got ','
True: Expected ',' got ','
True: Expected ',' got ','
True: Expected ',' got ','
True: Expected ' ' got ' '
True: Expected '|' got '|'
True: Expected '|' got '|'
True: Expected '|' got '|'
True: Expected '\t' got '\t'
"""


More information about the Python-bugs-list mailing list