Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4ppc (Windows Mobile) > Questions (Windows Mobile)
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Questions (Windows Mobile) Post any question regarding Basic4ppc.

CSV file generates strange start in file

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-20-2007, 11:23 AM
Junior Member
 
Join Date: Dec 2007
Posts: 32
Default CSV file generates strange start in file

If I save a file like:
Table1.SaveCSV ("data.csv", "," ,False)
and I open the file there are strange things in the file:
The three fist are:

After that it's like a planned to save it for example the text 'TEXT":
TEXT,ARTICLE
What am I doing wrong?
Reply With Quote
  #2 (permalink)  
Old 12-20-2007, 11:27 AM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,726
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

This is UTF-8 marking (BOM).
You could usually ignore it.
Reply With Quote
  #3 (permalink)  
Old 12-20-2007, 01:34 PM
Junior Member
 
Join Date: Dec 2007
Posts: 32
Default

Your are probably right. There is no way to concel these first three? The problem is that my application that want to import this file can not use it because of this.
Reply With Quote
  #4 (permalink)  
Old 12-20-2007, 01:46 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,726
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

You can use BinaryFile library to read the complete csv file except of the three first bytes and save it to a new file.
Please tell me if you need any help.
Reply With Quote
  #5 (permalink)  
Old 12-20-2007, 02:51 PM
Junior Member
 
Join Date: Dec 2007
Posts: 32
Default

Would be great if you could help me with it!
Reply With Quote
  #6 (permalink)  
Old 12-20-2007, 03:50 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,726
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

This is the code (it is also attached):
Code:
Sub Globals
    
Dim buffer(0As byte
End Sub

Sub App_Start
    RemoveBOM(
"1.csv","new2.csv"
End Sub

Sub RemoveBOM(file,NewFile)
    FileOpen(c,
file,cRandom)
    bin.New1(c,
true)
    size = FileSize(
file)-3
    
Dim buffer(size) As byte
    bin.ReadBytes(buffer(),
3'pass the BOM
    bin.ReadBytes(buffer(),size)
    FileClose(c)
    FileDel(NewFile)
    FileOpen(c2,NewFile,cRandom)
    bin.New1(c2,
true)
    bin.WriteBytes(buffer())
    FileClose(c2)
End Sub
It creates a new file without the utf8 marking.
Attached Files
File Type: zip RemoveBOM.zip (3.1 KB, 24 views)
Reply With Quote
  #7 (permalink)  
Old 12-20-2007, 06:32 PM
Junior Member
 
Join Date: Dec 2007
Posts: 32
Default

Thanks, only it does not work. Maybe it's because I work with tables:

Table1.AddRow(QT.Text,Leeg1.text,leeg2.text)
Table1.SaveCSV("LGXVRDMU.csv", ",", False)
Reply With Quote
  #8 (permalink)  
Old 12-20-2007, 06:47 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,726
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

Did you try to do:
Table1.AddRow(QT.Text,Leeg1.text,leeg2.text)
Table1.SaveCSV("LGXVRDMU.csv", ",", False)
RemoveBOM("LGXVRDMU.csv","NewFile.csv")
Reply With Quote
  #9 (permalink)  
Old 12-21-2007, 08:02 PM
Junior Member
 
Join Date: Dec 2007
Posts: 32
Default

yes I did; a get an error:
error compiling
bin is not a known control or object
bin.New1(c,true)
Reply With Quote
  #10 (permalink)  
Old 12-21-2007, 08:38 PM
Junior Member
 
Join Date: Dec 2007
Posts: 32
Default

Never mind. Forgot to load the dll-file!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help File bdiscount Questions (Windows Mobile) 2 01-13-2008 04:46 PM
Setting an .EXE B4P file to run from WM5 start menu. burd27 Questions (Windows Mobile) 1 01-06-2008 12:14 PM
F1 to Help File enonod Basic4ppc Wishlist 1 10-12-2007 05:06 PM
CAB File jorgerhv Questions (Windows Mobile) 1 05-16-2007 05:46 AM
ini-file sloopa Questions (Windows Mobile) 6 05-04-2007 07:06 PM


All times are GMT. The time now is 01:39 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0