NoizeBit

Read all lines of file excluding first one

8 posts in this topic

Hi again!

Looking for the easiest/shortest method to read all lines of a file except for the first one (csv header):

FileRead($sSourceCSV)

Thanks in advance!

Share this post


Link to post
Share on other sites



#include <MsgBoxConstants.au3>
Global $Skipline = 0 ;0==> first line

Example()


Func Example()
    ; Read the current script file into an array using the filepath.
    Local $aArray = FileReadToArray(@ScriptFullPath)
    If @error Then
        MsgBox($MB_SYSTEMMODAL, "", "There was an error reading the file. @error: " & @error) ; An error occurred reading the current script file.
    Else
        Local $temprf
        For $i = 0 To UBound($aArray) - 1 ; Loop through the array.
            If $Skipline = $i Then ContinueLoop
            $temprf &= $aArray[$i]
        Next
    EndIf
    MsgBox(0, 0, $temprf)
EndFunc   ;==>Example

 

1 person likes this

Share this post


Link to post
Share on other sites
#include <MsgBoxConstants.au3>
Global $Skipline = 0 ;0==> first line

Example()


Func Example()
    ; Read the current script file into an array using the filepath.
    Local $aArray = FileReadToArray(@ScriptFullPath)
    If @error Then
        MsgBox($MB_SYSTEMMODAL, "", "There was an error reading the file. @error: " & @error) ; An error occurred reading the current script file.
    Else
        Local $temprf
        For $i = 0 To UBound($aArray) - 1 ; Loop through the array.
            If $Skipline = $i Then ContinueLoop
            $temprf &= $aArray[$i]
        Next
    EndIf
    MsgBox(0, 0, $temprf)
EndFunc   ;==>Example

 

Awesome, just what I was looking for. Thanks a bunch, Celtic88 ;)

Share this post


Link to post
Share on other sites

Awesome, just what I was looking for. Thanks a bunch, Celtic88 ;)

One more thing: how could I add line breaks (@CRLF) after every line to maintain the original format as result?
Right now the result is one really long line ^_^

Share this post


Link to post
Share on other sites

add & @crlf    

Saludos

 

1 person likes this

Share this post


Link to post
Share on other sites

add & @crlf    

Saludos

 

Thanks ^_^

Share this post


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