Navigate
Wasp Helpdesk
  • Register

  • or
  • Login
    Need a password reminder?
or
Contact Us
  • Get in touch

    Send us an email

  • Start a chat session

  • Knowledgebase Read help articles
  • News News & updates
  • Contact Us We are here to help
  • Training View our options
  • Product Sunsets Non-Supported Products
Barcode System Consult
Barcode Printer Consult
Barcode Label Consult
  • Portal
  • Knowledgebase
  • Cloud
  • AssetCloud/InventoryCloud: PowerShell script to split large CSV files into smaller files
Subscribe Download PDF

AssetCloud/InventoryCloud: PowerShell script to split large CSV files into smaller files

Jason Whitmer
2022-03-23
in Cloud

The Bulk Attachment Importer tries to regulate the size of the exported attachment files based on the number of records. However, if the individual attachments are too large, this can produce a file that is too large to easily import into the new system.

If you need to break one of these large files up, you can use the script below in PowerShell with a few tweaks:

1. Enter the correct path\filename for your large file on the first line.
2. Enter the desired path for it to create the new smaller files on the second line.
3. On the third line, change 1000 to the desired number of records per file. This will vary depending on your data, but ideally the resulting files should be no larger than 250-500 MB each.

============

$InputFilename = Get-Content 'C:\path\filename.csv'
$OutputFilenamePattern = 'C:\path\output-filename_'
$LineLimit = 1000
$line = 0
$i = 0
$file = 0
$start = 0
while ($line -le $InputFilename.Length) {
if ($i -eq $LineLimit -Or $line -eq $InputFilename.Length) {
$file++
$Filename = "$OutputFilenamePattern$file.csv"
$InputFilename[$start..($line-1)] | Out-File $Filename -Force
$start = $line;
$i = 0
Write-Host "$Filename"
}
$i++;
$line++
}

Rate the quality of this page

This page was helpful :) :( This page was not helpful

30 of 36 people found this page helpful


Quick Jump
  • Wasp Helpdesk
  • Knowledgebase
  • News
  • Contact Us
Top
Helpdesk software provided by Deskpro