*.csv file with CR/LF character

malci

Member
Licensed User
Longtime User
hello.

I have a problem with CR / LF characters.
Excel makes me *. csv file with CR / LF characters at the end of each line, but does not know StringUtils library symbol CR.

Is there a possibility that with the command "StringUtils1.LoadCSV (dir, Filename,",")" to open the *. csv file with excel made​​?

Does anyone know what the VB macro to remove the CR character at the end of each row in excel *. csv file?

thanks for your help

by
Uros
 

malci

Member
Licensed User
Longtime User
"correctly"? Ok, but how I use it?
if I save *. csv file with the command "StringUtils1.SaveCSV2 (Dir, Filename," ", Sheet1, headers)" is not written to the CR character. And so the file can be opened by "StringUtils1.LoadCSV2 (Dir, Filename," ", headers)" without error. If you open the file with CR / LF ending, we make a mistake B4a "LastException java.lang.StringIndexOutOfBoundsException". I use the following code.

Where do I make a mistake?

by
uros

B4X:
Sub LoadTableFromCSV

Dim fd As FileDialog
Dim filename As String
Dim dir As String
Dim ret As String
Dim list1 As List
Dim Vrsta() As String
Dim x As Int

fd.FilePath="/mnt/sdcard/my document/El izdajnice"
fd.ShowOnlyFolders = False
fd.FastScroll = True


ret = fd.Show("Izberi datoteko", "Yes", "No", "Maybe", Bmp)   


   For i = table.NumberOfViews -1 To 0 Step -1
      table.RemoveViewAt(i)
   Next
 table.Height = 0dip
'x=table.NumberOfViews
'Log("table numberofviews after: " & x)

list1=StringUtils1.LoadCSV(dir,Filename,";")

x=list1.Size
Log ("size list1: " & x)
      ColumnWidth(0) = 10%x      
      ColumnWidth(1) = 55%x
      ColumnWidth(2) = 20%x
      ColumnWidth(3) = 15%x
      TotalColumnWidth(0) = 0dip
For ii=0 To list1.Size-1
   Vrsta = List1.Get(ii)
   For i = 0 To 4
      Dim l As Label
      l.Initialize("cell")
      l.Text = vrsta(i)
      l.Gravity = Alignment
      l.TextSize = FontSize
      l.TextColor = FontColor
      Dim rc As RowCol
      rc.Initialize
      rc.Col = i
      rc.Row = NumberOfRows
      l.Tag = rc
      
      table.AddView(l, TotalColumnWidth(i), RowHeight * NumberOfRows, ColumnWidth(i), RowHeight)
   Next
      Table.Height = NumberOfRows * RowHeight
Next
   Page3.naziv=GetCell(2,3)
End Sub
 

Attachments

  • lukovica save vith SaveCSV2.JPG
    lukovica save vith SaveCSV2.JPG
    80.2 KB · Views: 533
  • file save with Ecxel.JPG
    file save with Ecxel.JPG
    86.4 KB · Views: 592
Upvote 0

malci

Member
Licensed User
Longtime User
No problem.
When I try to load "NNO Hotedaršica.csv"( create by excel) Android application makes a mistake.

When the upload file "lukovica.csv" (create by andoroid app) everything is all right.

by
uros
 

Attachments

  • NNO Hotedaršica.zip
    704 bytes · Views: 285
  • lukovica.zip
    784 bytes · Views: 270
Upvote 0

malci

Member
Licensed User
Longtime User
Hi!

The above example does not work for me. I enclose an application to your case (with DirAsset *. csv file). I think it's really an error in the format *. csv file. Do you have any idea how to fix it?

Thank you for your efforts

by,
Uros
 
Upvote 0

malci

Member
Licensed User
Longtime User
hi!

I found a mistake. The *. csv file, some rows have a 3-columns, some with 4-columns.

thanks for your help


by
uros
 
Upvote 0
Top