Jump to content

[SOLVED] FileRead / FileReadLine a TSV doesn't return anything


Recommended Posts

I have a TSV file that I want to read but can't seem to.

It opens without an error but fails on FIleRead giving me error 1 which, as per the documentation, happens when file is not opened in read mode (not my case, I use the 0 parameter with FileOpen) OR other error, which is pretty vague.

$sFilePath = "G:\Čest\test.tsv"
Local $hFileOpen = FileOpen($sFilePath, 0)
If @error Then
    MsgBox(1, "error fileopen", @error) ; getting no errors when opening the file
EndIf

$test = FileRead($hFileOpen)
If @error Then
    MsgBox(1, "error FileRead", @error) ; here's where I get the error
EndIf

FileClose($hFileOpen)

I googled and found a similar case where there we null characters in the binary. The example given to identify those chars was this one:

Local $h_open = FileOpen("G:\Čest\test.tsv", 16)
Local $s_binary = FileRead($h_open)
FileClose($h_open)
Local $i
For $i = 1 To BinaryLen($s_binary)
    If Execute(BinaryMid($s_binary, $i, 1)) = 0 Then
        MsgBox(16, "Oops", "Character: " & $i & " is a NULL char.")
    EndIf
Next

However, no MsgBox with null chars...

Any ideas why I can't read the file?

 

EDIT: I can't seem to read any file, even txt.

Edited by Seminko
Link to post
Share on other sites

Found the issue. Leaving it here since it might be useful for others.

The actual filePath had a czech character - 'Č', so let's say 'G:\Čest\test.tsv'

I had my encoding set to Code Page Property instead of UTF-8.

For some reason fileopen didn't throw an error but fileread did.

Might that be a bug?

 

Obviously after changing the encoding to UTF-8 the problem went away.

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...