lesmly Posted November 8, 2016 Posted November 8, 2016 Hi, I've got a problem. My simple script is: #include <File.au3> #include <Array.au3> $filein = "C:\test.txt" Local $tablefromfile _FileReadToArray($filein, $tablefromfile, Default, "|") _ArrayDisplay($tablefromfile) File test.txt: a|b| When in file test.txt after "b" there is no "Enter" or there is one "Enter" - everything is OK, but when there are more "Enter", or "Space" in the second line - didn't work. Why? How can I read correctly file with many "Enter" after text?
Moderators Melba23 Posted November 8, 2016 Moderators Posted November 8, 2016 lesmly, You are telling the function that it should split the lines on the "|" character - and so it does. You then add further lines which do not contain that character - and the function fails with @error 3 (you did test this yourself?) as explained in the Help file: Quote @error: 3 - File lines have different numbers of fields (only if $FRTA_INTARRAYS flag not set) Remarks: When a delimiter is specified the function tries to further split each line of the file - how this is done depends on the setting of the $FRTA_INTARRAYS flag. If the flag is not set and each line has the same number of fields split by the delimiter then a 2D array is created, but if this is not the case then @error is set to 3 and no array is returned When used with the $sDelimiter parameter, the function expects a "square" file with each line having the same number of delimited items - in your case the lines do not meet this criterion and so the function fails. You have 2 choices: 1. - Use the $FRTA_INTARRAYS parameter to get an array of arrays - as explained in the Help file: Quote If the $FRTA_INTARRAYS flag is set the function creates a 1D array where each element is a further array holding the fields of the line split on the delimiter - the lines do not need to have the same number of fields 2. - Do not use the $sDelimiter parameter and split each line individually when required. Please ask if you have any further questions. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now