looking for some automation regarding csv file spl...
# csvimports
a
looking for some automation regarding csv file splitter. As we all know Netsuite has a limit of 25000 lines in csv import. In my case I have more than 150 000 lines. The problem is that my lnes are transactions data with multiple lines so when splitting to smaller files I have to pay attention to group of rows of the same tranaction I mean I can't put some rows of the same transaction into one file and other rows into another file. And all these simple splitters I can found in internet doesn't fit as they simply splits based on number of lines only. So does anyone use some tools or all play manually via copy pasting ?
m
Here at Celigo our Data Loader is free and can handle multi-line transactions, and scale without requiring you to split the file. It uses the same engine as our iPaaS too, in case you have more complex needs later. https://docs.celigo.com/hc/en-us/articles/226949488-Create-a-Data-Loader-flow#CSV
n
From Excel. Create a new Macro. Paste this code in. Take a look at the code comments on where you may want to edit it for your needs
Copy code
Sub splitFileGS()

Dim ACS As Range, Z As Long, New_WB As Workbook, _
Total_Columns As Long, Start_Row As Long, Stop_Row As Long, Copied_Range As Range

Dim Headers() As Variant

Set ACS = ActiveSheet.UsedRange

With ACS

    Headers = .Rows(1).Value
    Total_Columns = .Columns.Count
    
End With

Start_Row = 2

Do While Stop_Row <= ACS.Rows.Count
    
    Z = Z + 1
    
    If Z > 1 Then Start_Row = Stop_Row + 1
    
    Stop_Row = Start_Row + 24500 'edit your record count here. Mine is 24,500 rows per file.
            
    
    With ACS.Rows
        If Stop_Row > .Count Then Stop_Row = .Count
    End With
    
    With ACS
        Set Copied_Range = .Range(.Cells(Start_Row, 1), .Cells(Stop_Row, Total_Columns))
    End With
    
    Set New_WB = Workbooks.Add
    
    With New_WB
    
        With .Worksheets(1)
            .Cells(1, 1).Resize(1, Total_Columns) = Headers
            .Cells(2, 1).Resize(Copied_Range.Rows.Count, Total_Columns) = Copied_Range.Value
        End With
       
       'can find more file types here: <https://docs.microsoft.com/en-us/office/vba/api/excel.xlfileformat>
       'you will need extension: .csv .xlsx etc and file format id. 6 is .csv
       'you can change filename by editing in the quotes. e.g. file-z. z is the count
              
       .SaveAs ACS.Parent.Parent.Path & Application.PathSeparator & "file-" & Z & ".csv", FileFormat:=6
       .Close
       
    End With
    
    If Stop_Row = ACS.Rows.Count Then Exit Do
    
Loop

End Sub
👍 1
But I agree with @matt.graney on Celigo 🙂
🙂 2
j
i ended up writing a perl script for this as for example, if you are importing invoice with multiple transactions lines, you can't split arbitrarily. you have to split at the change of invoice number iirc.
a
thank you all for comments.