aswinkarthik / csvdiff

A fast diff tool for comparing csv files
https://aswinkarthik.github.io/csvdiff/
MIT License
532 stars 57 forks source link

panic: runtime error: index out of range [1] with length 0 #41

Closed kernelzeroday closed 4 years ago

kernelzeroday commented 4 years ago

Hey, I get a runtime issue when using this command:

$ csvdiff --columns '1,2,3,4' -p 1 csv/bno_1582942483.csv csv/bno_1582992337.csv

# Additions (2)
+ Qatar,1,0,
+ Ecuador,1,0,
# Modifications (32)
- Guangdong province,1348,7,"21 serious, 22 critical"
+ Guangdong province,1349,7,"18 serious, 20 critical"
- Henan province,1272,20,"9 serious, 9 critical"
+ Henan province,1272,21,"7 serious, 6 critical"
- Zhejiang province,1205,1,"10 serious, 11 critical"
+ Zhejiang province,1205,1,"10 serious, 9 critical"
- Hunan province,1017,4,18 serious
+ Hunan province,1018,4,19 serious
- Beijing,410,7,
+ Beijing,411,8,
- Shanghai,337,3,"9 serious, 3 critical"
+ Shanghai,337,3,10 serious
- Other regions,7321,64,
+ Other regions,7322,64,
- TOTAL,5931,88,151 serious/critical
+ TOTAL,79251,2835,"7,664 serious39,002 recovered1,418 suspected"
- South Korea,2931,16,"7 critical, 24 recovered"
+ South Korea,3150,17,"10 critical, 24 recovered"
- Iran,388,34,73 recovered
+ Iran,593,43,123 recovered
- Japan,234*,5,"20 serious, 32 recovered"
+ Japan,241*,5,"20 serious, 32 recovered"
- Singapore,96,0,"8 critical, 66 recovered"
+ Singapore,102,0,"7 critical, 72 recovered"
- Germany,48,0,"2 critical, 16 recovered"
+ Germany,79,0,"2 critical, 16 recovered"
- United States,64,0,"1 serious, 6 recovered"
+ United States,66,0,"1 serious, 7 recovered"
- France,57,2,"1 serious, 11 recovered"
+ France,73,2,"1 serious, 12 recovered"
- Spain,32,0,"1 serious, 2 recovered"
+ Spain,45,0,"1 serious, 2 recovered"
- Thailand,41,0,"2 serious, 15 recovered"
+ Thailand,42,0,"2 critical, 28 recovered"
- Taiwan,34,1,5 recovered
+ Taiwan,39,1,5 recovered
- Bahrain,38,0,
+ Bahrain,41,0,
- United Kingdom,20,0,8 recovered
+ United Kingdom,23,0,8 recovered
- Canada,15,0,3 recovered
+ Canada,16,0,3 recovered
- Sweden,11,0,
+ Sweden,12,0,
- Oman,6,0,
+ Oman,6,0,1 recovered
- Austria,6,0,
+ Austria,9,0,
- Croatia,5,0,
+ Croatia,6,0,
- Pakistan,2,0,
+ Pakistan,4,0,
- Georgia,1,0,
+ Georgia,3,0,
- Norway,6,0,
+ Norway,7,0,
- Denmark,2,0,
+ Denmark,3,0,
- Netherlands,2,0,
+ Netherlands,6,0,
- Mexico,2,0,
+ Mexico,3,0,
panic: runtime error: index out of range [1] with length 0

goroutine 1 [running]:
github.com/aswinkarthik/csvdiff/pkg/digest.Positions.String(0xc0001360e0, 0x4, 0x4, 0x0, 0x0, 0x0, 0x2c, 0xc000135840, 0xb)
    /private/tmp/csvdiff-20200229-14031-ibocos/csvdiff-1.4.0/pkg/digest/positions.go:35 +0x320
github.com/aswinkarthik/csvdiff/cmd.(*Formatter).lineDiff(0xc000197b28, 0xc00011cf00, 0x2, 0x2, 0xc000200000, 0x20, 0x20, 0xc00012a480, 0x1, 0x1, ...)
    /private/tmp/csvdiff-20200229-14031-ibocos/csvdiff-1.4.0/cmd/formatter.go:203 +0x650
github.com/aswinkarthik/csvdiff/cmd.(*Formatter).Format(0xc000197b28, 0xc00011cf00, 0x2, 0x2, 0xc000200000, 0x20, 0x20, 0xc00012a480, 0x1, 0x1, ...)
    /private/tmp/csvdiff-20200229-14031-ibocos/csvdiff-1.4.0/cmd/formatter.go:49 +0x17f
github.com/aswinkarthik/csvdiff/cmd.runContext(0xc000190000, 0x14759c0, 0xc000130008, 0x14759c0, 0xc000130010, 0x0, 0x0)
    /private/tmp/csvdiff-20200229-14031-ibocos/csvdiff-1.4.0/cmd/root.go:108 +0x4fe
github.com/aswinkarthik/csvdiff/cmd.glob..func2(0x16f5380, 0xc000132300, 0x2, 0x6, 0x0, 0x0)
    /private/tmp/csvdiff-20200229-14031-ibocos/csvdiff-1.4.0/cmd/root.go:87 +0x392
github.com/spf13/cobra.(*Command).execute(0x16f5380, 0xc000138010, 0x6, 0x6, 0x16f5380, 0xc000138010)
    /private/tmp/csvdiff-20200229-14031-ibocos/csvdiff-1.4.0/.brew_home/go/pkg/mod/github.com/spf13/cobra@v0.0.5/command.go:826 +0x453
github.com/spf13/cobra.(*Command).ExecuteC(0x16f5380, 0xc00011ae90, 0xc00003ef48, 0x1042b3a)
    /private/tmp/csvdiff-20200229-14031-ibocos/csvdiff-1.4.0/.brew_home/go/pkg/mod/github.com/spf13/cobra@v0.0.5/command.go:914 +0x2fb
github.com/spf13/cobra.(*Command).Execute(...)
    /private/tmp/csvdiff-20200229-14031-ibocos/csvdiff-1.4.0/.brew_home/go/pkg/mod/github.com/spf13/cobra@v0.0.5/command.go:864
github.com/aswinkarthik/csvdiff/cmd.Execute()
    /private/tmp/csvdiff-20200229-14031-ibocos/csvdiff-1.4.0/cmd/root.go:115 +0x76
main.main()
    /private/tmp/csvdiff-20200229-14031-ibocos/csvdiff-1.4.0/main.go:29 +0x59

CSV files:

china,location,Cases,Deaths,Notes,date2,unixtime
inside,Hubei province (includes Wuhan),66337,2727,"7,370 serious",Fri Feb 28 18:14:43 PST 2020,1582942483
inside,Guangdong province,1348,7,"21 serious, 22 critical",Fri Feb 28 18:14:43 PST 2020,1582942483
inside,Henan province,1272,20,"9 serious, 9 critical",Fri Feb 28 18:14:43 PST 2020,1582942483
inside,Zhejiang province,1205,1,"10 serious, 11 critical",Fri Feb 28 18:14:43 PST 2020,1582942483
inside,Hunan province,1017,4,18 serious,Fri Feb 28 18:14:43 PST 2020,1582942483
inside,Beijing,410,7,,Fri Feb 28 18:14:43 PST 2020,1582942483
inside,Shanghai,337,3,"9 serious, 3 critical",Fri Feb 28 18:14:43 PST 2020,1582942483
inside,Other regions,7321,64,,Fri Feb 28 18:14:43 PST 2020,1582942483
inside,Undisclosed,4,2,,Fri Feb 28 18:14:43 PST 2020,1582942483
inside,TOTAL,79251,2835,"7,664 serious39,002 recovered1,418 suspected",Fri Feb 28 18:14:43 PST 2020,1582942483
outside,Diamond Princess,705,6,"36 serious, 10 recovered",Fri Feb 28 18:14:43 PST 2020,1582942483
outside,South Korea,2931,16,"7 critical, 24 recovered",Fri Feb 28 18:14:43 PST 2020,1582942483
outside,Italy,889,21,"64 serious, 46 recovered",Fri Feb 28 18:14:43 PST 2020,1582942483
outside,Japan,234*,5,"20 serious, 32 recovered",Fri Feb 28 18:14:43 PST 2020,1582942483
outside,Iran,388,34,73 recovered,Fri Feb 28 18:14:43 PST 2020,1582942483
outside,Singapore,96,0,"8 critical, 66 recovered",Fri Feb 28 18:14:43 PST 2020,1582942483
outside,Hong Kong,93,2,"4 critical, 2 serious, 18 recovered",Fri Feb 28 18:14:43 PST 2020,1582942483
outside,United States,64,0,"1 serious, 6 recovered",Fri Feb 28 18:14:43 PST 2020,1582942483
outside,Thailand,41,0,"2 serious, 15 recovered",Fri Feb 28 18:14:43 PST 2020,1582942483
outside,Taiwan,34,1,5 recovered,Fri Feb 28 18:14:43 PST 2020,1582942483
outside,Malaysia,25,0,17 recovered,Fri Feb 28 18:14:43 PST 2020,1582942483
outside,Australia,25,0,15 recovered,Fri Feb 28 18:14:43 PST 2020,1582942483
outside,Germany,48,0,"2 critical, 16 recovered",Fri Feb 28 18:14:43 PST 2020,1582942483
outside,Vietnam,16,0,16 recovered,Fri Feb 28 18:14:43 PST 2020,1582942483
outside,UAE,19,0,"2 serious, 5 recovered",Fri Feb 28 18:14:43 PST 2020,1582942483
outside,United Kingdom,20,0,8 recovered,Fri Feb 28 18:14:43 PST 2020,1582942483
outside,France,57,2,"1 serious, 11 recovered",Fri Feb 28 18:14:43 PST 2020,1582942483
outside,Canada,15,0,3 recovered,Fri Feb 28 18:14:43 PST 2020,1582942483
outside,Macau,10,0,6 recovered,Fri Feb 28 18:14:43 PST 2020,1582942483
outside,Bahrain,38,0,,Fri Feb 28 18:14:43 PST 2020,1582942483
outside,Kuwait,45,0,,Fri Feb 28 18:14:43 PST 2020,1582942483
outside,Iraq,8,0,,Fri Feb 28 18:14:43 PST 2020,1582942483
outside,Philippines,3,1,2 recovered,Fri Feb 28 18:14:43 PST 2020,1582942483
outside,India,3,0,3 recovered,Fri Feb 28 18:14:43 PST 2020,1582942483
outside,Russia,2,0,2 recovered,Fri Feb 28 18:14:43 PST 2020,1582942483
outside,Spain,32,0,"1 serious, 2 recovered",Fri Feb 28 18:14:43 PST 2020,1582942483
outside,Oman,6,0,,Fri Feb 28 18:14:43 PST 2020,1582942483
outside,Nepal,1,0,1 recovered,Fri Feb 28 18:14:43 PST 2020,1582942483
outside,Cambodia,1,0,1 recovered,Fri Feb 28 18:14:43 PST 2020,1582942483
outside,Sri Lanka,1,0,1 recovered,Fri Feb 28 18:14:43 PST 2020,1582942483
outside,Finland,3,0,1 recovered,Fri Feb 28 18:14:43 PST 2020,1582942483
outside,Sweden,11,0,,Fri Feb 28 18:14:43 PST 2020,1582942483
outside,Belgium,1,0,1 recovered,Fri Feb 28 18:14:43 PST 2020,1582942483
outside,Egypt,1,0,1 recovered,Fri Feb 28 18:14:43 PST 2020,1582942483
outside,Israel,7,0,,Fri Feb 28 18:14:43 PST 2020,1582942483
outside,Lebanon,4,0,,Fri Feb 28 18:14:43 PST 2020,1582942483
outside,Afghanistan,1,0,,Fri Feb 28 18:14:43 PST 2020,1582942483
outside,Austria,6,0,,Fri Feb 28 18:14:43 PST 2020,1582942483
outside,Croatia,5,0,,Fri Feb 28 18:14:43 PST 2020,1582942483
outside,Switzerland,8,0,,Fri Feb 28 18:14:43 PST 2020,1582942483
outside,Algeria,1,0,,Fri Feb 28 18:14:43 PST 2020,1582942483
outside,Brazil,1,0,,Fri Feb 28 18:14:43 PST 2020,1582942483
outside,Greece,4,0,,Fri Feb 28 18:14:43 PST 2020,1582942483
outside,Pakistan,2,0,,Fri Feb 28 18:14:43 PST 2020,1582942483
outside,North Macedonia,1,0,,Fri Feb 28 18:14:43 PST 2020,1582942483
outside,Georgia,1,0,,Fri Feb 28 18:14:43 PST 2020,1582942483
outside,Norway,6,0,,Fri Feb 28 18:14:43 PST 2020,1582942483
outside,Romania,3,0,,Fri Feb 28 18:14:43 PST 2020,1582942483
outside,Denmark,2,0,,Fri Feb 28 18:14:43 PST 2020,1582942483
outside,Estonia,1,0,,Fri Feb 28 18:14:43 PST 2020,1582942483
outside,Netherlands,2,0,,Fri Feb 28 18:14:43 PST 2020,1582942483
outside,San Marino,1,0,,Fri Feb 28 18:14:43 PST 2020,1582942483
outside,Nigeria,1,0,,Fri Feb 28 18:14:43 PST 2020,1582942483
outside,Lithuania,1,0,,Fri Feb 28 18:14:43 PST 2020,1582942483
outside,New Zealand,1,0,,Fri Feb 28 18:14:43 PST 2020,1582942483
outside,Belarus,1,0,,Fri Feb 28 18:14:43 PST 2020,1582942483
outside,Mexico,2,0,,Fri Feb 28 18:14:43 PST 2020,1582942483
outside,Azerbaijan,1,0,,Fri Feb 28 18:14:43 PST 2020,1582942483
outside,Iceland,1,0,,Fri Feb 28 18:14:43 PST 2020,1582942483
outside,Monaco,1,0,,Fri Feb 28 18:14:43 PST 2020,1582942483
outside,TOTAL,5931,88,151 serious/critical,Fri Feb 28 18:14:43 PST 2020,1582942483
china,location,Cases,Deaths,Notes,date2,unixtime
inside,Hubei province (includes Wuhan),66337,2727,"7,370 serious",Sat Feb 29 08:05:37 PST 2020,1582992337
inside,Guangdong province,1349,7,"18 serious, 20 critical",Sat Feb 29 08:05:37 PST 2020,1582992337
inside,Henan province,1272,21,"7 serious, 6 critical",Sat Feb 29 08:05:37 PST 2020,1582992337
inside,Zhejiang province,1205,1,"10 serious, 9 critical",Sat Feb 29 08:05:37 PST 2020,1582992337
inside,Hunan province,1018,4,19 serious,Sat Feb 29 08:05:37 PST 2020,1582992337
inside,Beijing,411,8,,Sat Feb 29 08:05:37 PST 2020,1582992337
inside,Shanghai,337,3,10 serious,Sat Feb 29 08:05:37 PST 2020,1582992337
inside,Other regions,7322,64,,Sat Feb 29 08:05:37 PST 2020,1582992337
inside,TOTAL,79251,2835,"7,664 serious39,002 recovered1,418 suspected",Sat Feb 29 08:05:37 PST 2020,1582992337
outside,South Korea,3150,17,"10 critical, 24 recovered",Sat Feb 29 08:05:37 PST 2020,1582992337
outside,Italy,889,21,"64 serious, 46 recovered",Sat Feb 29 08:05:37 PST 2020,1582992337
outside,Diamond Princess,705,6,"36 serious, 10 recovered",Sat Feb 29 08:05:37 PST 2020,1582992337
outside,Iran,593,43,123 recovered,Sat Feb 29 08:05:37 PST 2020,1582992337
outside,Japan,241*,5,"20 serious, 32 recovered",Sat Feb 29 08:05:37 PST 2020,1582992337
outside,Singapore,102,0,"7 critical, 72 recovered",Sat Feb 29 08:05:37 PST 2020,1582992337
outside,Hong Kong,93,2,"4 critical, 2 serious, 18 recovered",Sat Feb 29 08:05:37 PST 2020,1582992337
outside,Germany,79,0,"2 critical, 16 recovered",Sat Feb 29 08:05:37 PST 2020,1582992337
outside,United States,66,0,"1 serious, 7 recovered",Sat Feb 29 08:05:37 PST 2020,1582992337
outside,France,73,2,"1 serious, 12 recovered",Sat Feb 29 08:05:37 PST 2020,1582992337
outside,Spain,45,0,"1 serious, 2 recovered",Sat Feb 29 08:05:37 PST 2020,1582992337
outside,Kuwait,45,0,,Sat Feb 29 08:05:37 PST 2020,1582992337
outside,Thailand,42,0,"2 critical, 28 recovered",Sat Feb 29 08:05:37 PST 2020,1582992337
outside,Taiwan,39,1,5 recovered,Sat Feb 29 08:05:37 PST 2020,1582992337
outside,Bahrain,41,0,,Sat Feb 29 08:05:37 PST 2020,1582992337
outside,Malaysia,25,0,17 recovered,Sat Feb 29 08:05:37 PST 2020,1582992337
outside,Australia,25,0,15 recovered,Sat Feb 29 08:05:37 PST 2020,1582992337
outside,United Kingdom,23,0,8 recovered,Sat Feb 29 08:05:37 PST 2020,1582992337
outside,UAE,19,0,"2 serious, 5 recovered",Sat Feb 29 08:05:37 PST 2020,1582992337
outside,Vietnam,16,0,16 recovered,Sat Feb 29 08:05:37 PST 2020,1582992337
outside,Canada,16,0,3 recovered,Sat Feb 29 08:05:37 PST 2020,1582992337
outside,Sweden,12,0,,Sat Feb 29 08:05:37 PST 2020,1582992337
outside,Macau,10,0,6 recovered,Sat Feb 29 08:05:37 PST 2020,1582992337
outside,Iraq,8,0,,Sat Feb 29 08:05:37 PST 2020,1582992337
outside,Israel,7,0,,Sat Feb 29 08:05:37 PST 2020,1582992337
outside,Oman,6,0,1 recovered,Sat Feb 29 08:05:37 PST 2020,1582992337
outside,Philippines,3,1,2 recovered,Sat Feb 29 08:05:37 PST 2020,1582992337
outside,India,3,0,3 recovered,Sat Feb 29 08:05:37 PST 2020,1582992337
outside,Finland,3,0,1 recovered,Sat Feb 29 08:05:37 PST 2020,1582992337
outside,Russia,2,0,2 recovered,Sat Feb 29 08:05:37 PST 2020,1582992337
outside,Nepal,1,0,1 recovered,Sat Feb 29 08:05:37 PST 2020,1582992337
outside,Cambodia,1,0,1 recovered,Sat Feb 29 08:05:37 PST 2020,1582992337
outside,Sri Lanka,1,0,1 recovered,Sat Feb 29 08:05:37 PST 2020,1582992337
outside,Belgium,1,0,1 recovered,Sat Feb 29 08:05:37 PST 2020,1582992337
outside,Egypt,1,0,1 recovered,Sat Feb 29 08:05:37 PST 2020,1582992337
outside,Lebanon,4,0,,Sat Feb 29 08:05:37 PST 2020,1582992337
outside,Afghanistan,1,0,,Sat Feb 29 08:05:37 PST 2020,1582992337
outside,Austria,9,0,,Sat Feb 29 08:05:37 PST 2020,1582992337
outside,Croatia,6,0,,Sat Feb 29 08:05:37 PST 2020,1582992337
outside,Switzerland,8,0,,Sat Feb 29 08:05:37 PST 2020,1582992337
outside,Algeria,1,0,,Sat Feb 29 08:05:37 PST 2020,1582992337
outside,Brazil,1,0,,Sat Feb 29 08:05:37 PST 2020,1582992337
outside,Greece,4,0,,Sat Feb 29 08:05:37 PST 2020,1582992337
outside,Pakistan,4,0,,Sat Feb 29 08:05:37 PST 2020,1582992337
outside,North Macedonia,1,0,,Sat Feb 29 08:05:37 PST 2020,1582992337
outside,Georgia,3,0,,Sat Feb 29 08:05:37 PST 2020,1582992337
outside,Norway,7,0,,Sat Feb 29 08:05:37 PST 2020,1582992337
outside,Romania,3,0,,Sat Feb 29 08:05:37 PST 2020,1582992337
outside,Denmark,3,0,,Sat Feb 29 08:05:37 PST 2020,1582992337
outside,Estonia,1,0,,Sat Feb 29 08:05:37 PST 2020,1582992337
outside,Netherlands,6,0,,Sat Feb 29 08:05:37 PST 2020,1582992337
outside,San Marino,1,0,,Sat Feb 29 08:05:37 PST 2020,1582992337
outside,Nigeria,1,0,,Sat Feb 29 08:05:37 PST 2020,1582992337
outside,Lithuania,1,0,,Sat Feb 29 08:05:37 PST 2020,1582992337
outside,New Zealand,1,0,,Sat Feb 29 08:05:37 PST 2020,1582992337
outside,Belarus,1,0,,Sat Feb 29 08:05:37 PST 2020,1582992337
outside,Mexico,3,0,,Sat Feb 29 08:05:37 PST 2020,1582992337
outside,Azerbaijan,1,0,,Sat Feb 29 08:05:37 PST 2020,1582992337
outside,Iceland,1,0,,Sat Feb 29 08:05:37 PST 2020,1582992337
outside,Monaco,1,0,,Sat Feb 29 08:05:37 PST 2020,1582992337
outside,Qatar,1,0,,Sat Feb 29 08:05:37 PST 2020,1582992337
outside,Ecuador,1,0,,Sat Feb 29 08:05:37 PST 2020,1582992337
outside,TOTAL,6461,98,154 serious/critical,Sat Feb 29 08:05:37 PST 2020,1582992337
kernelzeroday commented 4 years ago

Whoops reread docs, was using -p incorrectly. Sorry.