Gianni M Well-Known Member Licensed User Longtime User Jun 14, 2019 #1 a file csv contain data: Code: Copy item1;alfa1;beta1 item2;alfa2;beta2 item3;alfa3;beta3 empty row empty row now, my code is: Code: Copy Dim su As StringUtils Dim ItemList As List ItemList = su.LoadCSV (myPath, NameCSV, ";") log error is: Code: Copy importcounter._leggicounter (java line: 137) java.lang.StringIndexOutOfBoundsException: String index out of range: -1680 at java.lang.String.substring(String.java:1967) at anywheresoftware.b4a.objects.StringUtils.ReadWord(StringUtils.java:243) at anywheresoftware.b4a.objects.StringUtils.LoadCSV2(StringUtils.java:207) at anywheresoftware.b4a.objects.StringUtils.LoadCSV(StringUtils.java:120) at j.Statistiche.importcounter._leggicounter(importcounter.java:137) at j.Statistiche.main._btcounter_action(main.java:100) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at anywheresoftware.b4a.BA.raiseEvent2(BA.java:91) at anywheresoftware.b4a.BA$1.run(BA.java:216) at com.sun.javafx.application.PlatformImpl.lambda$null$177(PlatformImpl.java:295) at java.security.AccessController.doPrivileged(Native Method) at com.sun.javafx.application.PlatformImpl.lambda$runLater$178(PlatformImpl.java:294) at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95) at com.sun.glass.ui.win.WinApplication._runLoop(Native Method) at com.sun.glass.ui.win.WinApplication.lambda$null$152(WinApplication.java:177) at java.lang.Thread.run(Thread.java:748) trouble is empty row at end of file CSV Is there a solution?
a file csv contain data: Code: Copy item1;alfa1;beta1 item2;alfa2;beta2 item3;alfa3;beta3 empty row empty row now, my code is: Code: Copy Dim su As StringUtils Dim ItemList As List ItemList = su.LoadCSV (myPath, NameCSV, ";") log error is: Code: Copy importcounter._leggicounter (java line: 137) java.lang.StringIndexOutOfBoundsException: String index out of range: -1680 at java.lang.String.substring(String.java:1967) at anywheresoftware.b4a.objects.StringUtils.ReadWord(StringUtils.java:243) at anywheresoftware.b4a.objects.StringUtils.LoadCSV2(StringUtils.java:207) at anywheresoftware.b4a.objects.StringUtils.LoadCSV(StringUtils.java:120) at j.Statistiche.importcounter._leggicounter(importcounter.java:137) at j.Statistiche.main._btcounter_action(main.java:100) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at anywheresoftware.b4a.BA.raiseEvent2(BA.java:91) at anywheresoftware.b4a.BA$1.run(BA.java:216) at com.sun.javafx.application.PlatformImpl.lambda$null$177(PlatformImpl.java:295) at java.security.AccessController.doPrivileged(Native Method) at com.sun.javafx.application.PlatformImpl.lambda$runLater$178(PlatformImpl.java:294) at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95) at com.sun.glass.ui.win.WinApplication._runLoop(Native Method) at com.sun.glass.ui.win.WinApplication.lambda$null$152(WinApplication.java:177) at java.lang.Thread.run(Thread.java:748) trouble is empty row at end of file CSV Is there a solution?
klaus Expert Licensed User Longtime User Jun 14, 2019 #2 giannimaione said: Is there a solution? Click to expand... Yes, remove the empty rows . Upvote 0
Gianni M Well-Known Member Licensed User Longtime User Jun 14, 2019 #3 changed Code: Copy Dim ItemList As List ItemList = File.ReadList (myPath, NameCSV) Dim OB() As Object For x = 0 to ItemList.Size-1 OB=Regex.Split(";", ItemList.Get(x)) 'here i have OB(0), OB(1), and OB(2) and i can test if it's empty Next Upvote 0
changed Code: Copy Dim ItemList As List ItemList = File.ReadList (myPath, NameCSV) Dim OB() As Object For x = 0 to ItemList.Size-1 OB=Regex.Split(";", ItemList.Get(x)) 'here i have OB(0), OB(1), and OB(2) and i can test if it's empty Next
klaus Expert Licensed User Longtime User Jun 14, 2019 #4 For me, the first question is: Why do you have empty rows in the file? Last edited: Jun 14, 2019 Upvote 0
Gianni M Well-Known Member Licensed User Longtime User Jun 14, 2019 #5 because, I receive an archive from some_several store counter (see image), via email. Attachments antitaccheggio.jpg 79.8 KB · Views: 743 Upvote 0
klaus Expert Licensed User Longtime User Jun 14, 2019 #6 Well, I understand. That means that their system is not working well, and of course, you cannot improuve it. Therefore, unfortunately, you need to check everything on your own. Upvote 0
Well, I understand. That means that their system is not working well, and of course, you cannot improuve it. Therefore, unfortunately, you need to check everything on your own.
R RWK Member Licensed User Longtime User Jun 14, 2019 #7 I have same problem with amazon Transfer Files... Don't know why the hell they are including 7 lines of bullshit text at the beginning of their export files... after that the data begins.. It would be fine if LoadCSV could be extended like Excel Import: Code: Copy Workbooks.OpenText Filename:=pfad, Origin:=65001, _ StartRow:=7, DataType:=xlDelimited, Comma:=True, local:=True Anyway....time to switch to get the data per Amazon Financal Data API Upvote 0
I have same problem with amazon Transfer Files... Don't know why the hell they are including 7 lines of bullshit text at the beginning of their export files... after that the data begins.. It would be fine if LoadCSV could be extended like Excel Import: Code: Copy Workbooks.OpenText Filename:=pfad, Origin:=65001, _ StartRow:=7, DataType:=xlDelimited, Comma:=True, local:=True Anyway....time to switch to get the data per Amazon Financal Data API
Erel B4X founder Staff member Licensed User Longtime User Jun 16, 2019 #8 Code: Copy Dim s As String = File.ReadString(...) s = s.Trim File.WriteString(..., s) 'load the new file Upvote 0
Code: Copy Dim s As String = File.ReadString(...) s = s.Trim File.WriteString(..., s) 'load the new file
raphael75 Active Member Licensed User Longtime User Jun 17, 2019 #9 giannimaione said: Code: Copy For x = 0 to ItemList.Size-1 Click to expand... You may add Code: Copy If ItemList.Size > 0 Then before Code: Copy For x = 0 to ItemList.Size-1 to avoid a crash Upvote 0
giannimaione said: Code: Copy For x = 0 to ItemList.Size-1 Click to expand... You may add Code: Copy If ItemList.Size > 0 Then before Code: Copy For x = 0 to ItemList.Size-1 to avoid a crash