Page Index Toggle Pages: [1] 2  Send Topic Send Topic Print Print
Hot Topic (More than 10 Replies) File Open is not working anymore. (Read 3354 times)
Steve_in_Texas
Senior Member
*****
Offline


No personal text

Posts: 893
Location: San Antonio
Joined: Feb 21st, 2004
File Open is not working anymore.
Aug 17th, 2004 at 7:31pm
Print Post Print Post  
For some reason, I cant get Sesame to open a .txt file. I've tried several different programs, and none of them will read the contents of the file. The file is a plain text file (copied from website and pasted into excel, then saved as .TXT). It opens fine in notepad:

var vall as string = ""
vall = @insert("c:\temp\colors5.txt")
writeln("vall = " + vall)

The writeln window is blank. also:

var vfilehandle as int
var vfilesize as int
var vfile as string
var vline as string = ""

if fileExists("C:\temp\colors5.txt") then writeln("Found it") else writeln("Cant find it!")

vfilehandle = fileopen("c:\temp\colors5.txt")
vfilesize= filesize(vfilehandle)
filereadln(vfilehandle, vline)
writeln(vline)

Here the writeln window shows "Found it"  and nothing else.

I restarted client, and put the text file in the c:\temp folder on BOTH client and server, but still no luck.

Any ideas? I've never had this problem before.

Steve
  
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: File Open is not working anymore.
Reply #1 - Aug 17th, 2004 at 7:39pm
Print Post Print Post  
Excel has a bunch of different formats it calls TXT. They do not all result in the format of text file you might expect. Can you open other text files that have not been processed in this way by Excel?
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Steve_in_Texas
Senior Member
*****
Offline


No personal text

Posts: 893
Location: San Antonio
Joined: Feb 21st, 2004
Re: File Open is not working anymore.
Reply #2 - Aug 17th, 2004 at 7:47pm
Print Post Print Post  
Yes, other text files are being opened just fine. Also, I've used this routine before and occasionally run into a problem where sesame doesnt find certain character such as @newline().

But it seems this time, sesame cant read any of it at all. Using @Asc(vline) just returns 0.

Can you think of a way to get the data in excel into a more Sesame friendly format? Pasting from Excel into notepad doesn't help and I dont see an 'export' tool in excel.

Thanks,
Steve


  
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: File Open is not working anymore.
Reply #3 - Aug 17th, 2004 at 8:06pm
Print Post Print Post  
Which of the txt options are you using from Excel? You might try tab delimited or csv and see if that helps. 

In Excel, Save As is how you "export". I've found Excel to be a bit flaky about doing this, especially in situations where, for example, the last cell is blank. Stuff like that.

Send us the text file. We'll look at in something that doesn't hide anything and let you know what we see.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Steve_in_Texas
Senior Member
*****
Offline


No personal text

Posts: 893
Location: San Antonio
Joined: Feb 21st, 2004
Re: File Open is not working anymore.
Reply #4 - Aug 17th, 2004 at 8:12pm
Print Post Print Post  
I always save as .csv from excel which usually works fine.

I'll send you the text file. Thanks for the help.

Steve
  
Back to top
IP Logged
 
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: File Open is not working anymore.
Reply #5 - Aug 17th, 2004 at 11:00pm
Print Post Print Post  
As noted earlier, not all TXT files are the same.  And NotePad does use a format that is not common to many other editors.  Unicode sometimes may also be a factor.

But let me question the use of Excel.  Is it really necessary?  You may be able to copy from the Web directly into a text editor of choice.

If you have copied a table, then you can do a Search/Replace in the editor replacing Tab chars with your comma, and save as text.

Can you provide the web link and describe what you are copying into the text file?


  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged
 
Steve_in_Texas
Senior Member
*****
Offline


No personal text

Posts: 893
Location: San Antonio
Joined: Feb 21st, 2004
Re: File Open is not working anymore.
Reply #6 - Aug 17th, 2004 at 11:14pm
Print Post Print Post  
Bob,

I copied a table (chart?) and which pasted nicely into excel. Then I used Excels features and speed to do a lot of search/replacing. Keeping things in neat rows and columns is essential.

Then I saved to a .csv and usually import it right into sesame using Sbasic programming.

Maybe I should look at search/replace program other than excel. (Notepad is SOO SLOOOWW, but necessary to 'clean up' the .csv before importing into Sesame)

Thanks,
Steve
  
Back to top
IP Logged
 
jondolar
Junior Member
**
Offline


Keep Trying

Posts: 57
Location: Montreal Canada
Joined: Dec 25th, 2003
Re: File Open is not working anymore.
Reply #7 - Aug 17th, 2004 at 11:28pm
Print Post Print Post  
Hi Steve

Use WordPad. It has a find and replace feature and comes standard with every version of Windows. Your "Cleaning job" will be much easier. Wink

Take care

Serge



  

When all you have is a hammer, everything starts to look like nail!
Back to top
 
IP Logged
 
Steve_in_Texas
Senior Member
*****
Offline


No personal text

Posts: 893
Location: San Antonio
Joined: Feb 21st, 2004
Re: File Open is not working anymore.
Reply #8 - Aug 18th, 2004 at 12:16am
Print Post Print Post  
Thanks Serge. I have found Word pad to be much faster, but I was worred that wordpad my add change my "generic text" to "Rich Text" and further complicate things during my import into sesame. Also, the 'wordwrap' throws my lines out of whack. I like to see the data as 'raw' as possible.

Thanks for all the suggestions. Keep em coming.

Steve
  
Back to top
IP Logged
 
Steve_in_Texas
Senior Member
*****
Offline


No personal text

Posts: 893
Location: San Antonio
Joined: Feb 21st, 2004
Re: File Open is not working anymore.
Reply #9 - Aug 18th, 2004 at 1:01am
Print Post Print Post  
Bob,

I tried another d/l of the text from the website. I saved it as a csv and opened it into notepad. All went well, I then saved it and tried to import it into sesame.....nothing. Sesame sees it as a blank file. It wont even writeln the to the screen. (same as before).

So this issue has nothing to do with Excel. The website that I'm getting the data from is not giving me plain text.

I'll need to wait to see what the Lanticans come up with.

Thanks for everyones help. Hopefully I'll hear from Erika tomorrow.

Steve


ps. I'd give you the link to the site, but its password protected info.

  
Back to top
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: File Open is not working anymore.
Reply #10 - Aug 18th, 2004 at 3:07pm
Print Post Print Post  
Steve,

I now have your file, and I am seeing a few problems, some with the SBasic (as posted) and a minor problem with the file.

The following SBasic will not work because of the length of the file: 
Code
Select All
var vall as string = ""
vall = @insert("c:\temp\colors5.txt")
writeln("vall = " + vall)
 


The file is 382K as received. The writeln window will vertically wrap every 32K (clear, and start at the top again) and dumping 382K on a single line is just too much for it to manage. You will need to break your string into smaller pieces if you need to send them to the writeln window, so each line of text is smaller.

The good news is that the variable "vall" is getting set to the entire string - even if that cannot be shown using a single writeln call.

The other attempt to read the file is suffering because, FileOpen expects to be used read/write - so if the file already exists it positions the "file pointer" (the position where the next operation will occur in the file) to the end of the file - to make appending to an existing file very easy. Before reading from an existing file, you should always do a "FileSeek" operation. The following will read the first line in your file:
Code
Select All
vfilehandle = fileopen("c:\temp\colors5.txt")
fileseek(vfilehandle, 0)
filereadln(vfilehandle, vline)
writeln(vline)
fileclose(vfilehandle)
 


The last problem I am seeing, is that the file is not "DOS" formatted. All operating systems other than those from Microsoft (Unixes, VMS, Mac, etc..) end each line with a single line feed. Microsoft OSs (on the other hand) end each line with a linefeed / carriage return pair. The file you sent only has the single linefeed. So, it appears that it originated on an operating system other than a Microsoft OS. This is not a bad problem because Sesame and most other programs are built to accomodate either line ending.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
Steve_in_Texas
Senior Member
*****
Offline


No personal text

Posts: 893
Location: San Antonio
Joined: Feb 21st, 2004
Re: File Open is not working anymore.
Reply #11 - Aug 18th, 2004 at 3:24pm
Print Post Print Post  
Thanks Mark, I assumed the fileseek was not needed. I'll add it to my routine.

Also, as I import this file into sesame, can I continue to use the 'split(vline, @newline())' command or are you saying there are no linefeeds in that file?

If not, what do I need to do to have sesame parse that file line by line? SHould I just go in and press enter at the end of each line in notepad (hopefully not).

Thanks again for your help,

Steve
  
Back to top
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: File Open is not working anymore.
Reply #12 - Aug 18th, 2004 at 4:54pm
Print Post Print Post  
Quote:
Thanks Mark, I assumed the fileseek was not needed. I'll add it to my routine.

Also, as I import this file into sesame, can I continue to use the 'split(vline, @newline())' command or are you saying there are no linefeeds in that file?

If not, what do I need to do to have sesame parse that file line by line? SHould I just go in and press enter at the end of each line in notepad (hopefully not).

Thanks again for your help,

Steve


The file does have linefeeds. It seems to missing carriage returns. That should be okay and you probably won't need to do anything about that.

I would recommend that you get rid of the @Insert and its accompanying WriteLn, and use the file I/O to read the file in one line at a time. That way, you do not have to parse it into separate lines at all. Once you have read a line you can parse it, or concatenate it, or merely send it to the "slate" with WriteLn - as is needed.

Anything you pass to WriteLn, WriteLn will treat as one big "chunk" even if it has linefeed embedded in it. It measures the string length - not the line length. A string can have many lines in it, each demarcated with either a single linefeed or a lf/cr pair.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
Steve_in_Texas
Senior Member
*****
Offline


No personal text

Posts: 893
Location: San Antonio
Joined: Feb 21st, 2004
Re: File Open is not working anymore.
Reply #13 - Aug 18th, 2004 at 5:54pm
Print Post Print Post  
Thanks again. I added the writeln just for the sake of this example and to see if it was working.

My problem lies in the fact that i didnt use FileSeek.

I'll give it a try.

Thanks for all your help.

Steve
  
Back to top
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: File Open is not working anymore.
Reply #14 - Aug 18th, 2004 at 5:57pm
Print Post Print Post  
You're welcome.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
Page Index Toggle Pages: [1] 2 
Send Topic Send Topic Print Print