Jump to content

File Write stops at line 5278


Recommended Posts

Hi guys,

me again.

So I've got this 2D array with about 6200 items in it (4 columns).

It seems that FileWrite, FileWriteLine, _FileWriteLine and _FileWriteFromArray  all stop at line 5278 (size 199KB).

I'm writing to a .csv with a For cycle. Any thoughts?

Thanks

Link to comment
Share on other sites

John, there's really not much, see below, this is the last test I made with just FileWrite, but as I said, I tried with FileWriteLine, _FileWriteToLine:

Local $hFileOpen = FileOpen($destination_file,$FO_OVERWRITE)
FileWrite($hFileOpen,"Name,Disabled,Last Logon,Description"&@CRLF)

For $i=1 To $CompleteArray[0][0]
 FileWrite($hFileOpen,$CompleteArray[$i][0]&','&$CompleteArray[$i][1]&','&$CompleteArray[$i][2]&','&$CompleteArray[$i][3]&@CRLF)
Next
FileClose($hFileOpen)

And same problem happens with this (which is the first thing I tried):

_FileWriteFromArray($destination_file,$CompleteArray,1,Default,",")

Obviously, _arrayDisplay() shows me all of the 6200 lines.

EDIT:

I tested the below, which works fine for all 100000 lines! It doesn't make any sense to me to be honest!

Local $hFileOpen = FileOpen($destination_file,$FO_OVERWRITE)
For $i=1 to 100000
    FileWriteLine($hFileOpen,"Name,Disabled,Last Logon,Description"&@CRLF)
Next
FileClose($hFileOpen)

Thanks

Edited by simy8891
Link to comment
Share on other sites

  • Moderators

simy8891,

I have just run this and got all 6200 lines into the file:

#include <Array.au3>
#include <File.au3>

$destination_file = "File.txt"
Global $CompleteArray[6201][4] = [[6200]]
For $i = 1 To 6200
    For $j = 0 To 3
        $CompleteArray[$i][$j] = $i & "-" & $j
    Next
Next

$hFileOpen = FileOpen($destination_file,$FO_OVERWRITE)
FileWrite($hFileOpen,"Name,Disabled,Last Logon,Description"&@CRLF)

For $i=1 To $CompleteArray[0][0]
 FileWrite($hFileOpen,$CompleteArray[$i][0]&','&$CompleteArray[$i][1]&','&$CompleteArray[$i][2]&','&$CompleteArray[$i][3]&@CRLF)
Next

FileClose($hFileOpen)

Global $aLines
_FileReadToArray($destination_file, $aLines)
_ArrayDisplay($aLines, "", Default, 8)
Can you try and see if you get the same result. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Hi Melba23,

yup, it worked. So did my quick test:

Local $hFileOpen = FileOpen($destination_file,$FO_OVERWRITE)
For $i=1 to 100000
    FileWriteLine($hFileOpen,"Name,Disabled,Last Logon,Description"&@CRLF)
Next
FileClose($hFileOpen)

Just to show you that I checked, this is the _arrayDisplay() of the array I have:

post-59007-0-24904200-1401188802_thumb.p

and the end:

post-59007-0-30147900-1401188902_thumb.p

Is there something else I could try?

Cheers

Edited by simy8891
Link to comment
Share on other sites

  • Moderators

simy8891,

Is there any chance that the array might hold an EOF marker? Then when you read the file it would seem to stop early. :huh:

I suggest using ConsoleWrite to check that you are actually writing all 6200 lines and using Binary to look at the actual bytes written:

For $i = 1 To $CompleteArray[0][0]
    $sLine =  $CompleteArray[$i][0] & ',' & $CompleteArray[$i][1] & ',' & $CompleteArray[$i][2] & ',' & $CompleteArray[$i][3]
    FileWrite($hFileOpen, $sLine & @CRLF)
    ConsoleWrite($i & ": " & $sLine & @CRLF & Binary($sLine) & @CRLF)
Next
Then when you see the file is truncated, look at the line in question and see if the binary content gives us a clue. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Ehmmm guys.. I found the problem.. it's called in part Excel 2013 and in part a System Eng. who doesn't know how to end a sentence!

When editing the .csv file with Notepad++ for instance, I can see them all. But I went on the actual line where it stopped, I've noticed (in N++) that there's was a quote " sign in the description. I went to check in AD (this is exported from AD) and the description didn't match, BUT, it ended with a "," rather than with nothing or with a ".".

Anyway, I removed the comment in AD and it went just fine.. for now :)

Thanks

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...