2

I’m using Toad for Oracle to access 11G environment and my dataset has 1,000,000 records. While downloading I want to split the files in 100,000 each 10 files. I do not have the authority to create tables instead I can run and download only. Is their a way I can split the files while downloading?

Data Downloader Image

Barbaros Özhan
  • 59,113
  • 10
  • 31
  • 55

1 Answers1

0

You can split a text file using PowerShell or linux shell.

How to Split Large Text File into Smaller Files in Linux

  • example for linux

    #split -l 100000 test.txt new

  • example for Windows

How can I split a text file using PowerShell?

split_log.ps1
    param(
    [string]$input_file = "",
    [string]$count_line = ""
    )
    $lineCount = 0
    $fileCount = 1

    foreach ($line_file in get-content $input_file)
    {
        write $line_file | out-file -encoding ASCII -Append $input_file"_"$fileCount".out"
        $lineCount++

        if ($lineCount -eq $count_line)
        {
            $fileCount++
            $lineCount = 0
        }
    }




       PS C:\АСУ\Stackoverflow\split_log> ls


    Каталог: C:\АСУ\Stackoverflow\split_log


Mode                LastWriteTime     Length Name
----                -------------     ------ ----
-a---        17.12.2018      6:03   10959355 1124.sql
-a---        17.12.2018      7:27        357 split_log.ps1


PS C:\АСУ\Stackoverflow\split_log> .\split_log.ps1 .\1124.sql 10000
PS C:\АСУ\Stackoverflow\split_log> ls


    Каталог: C:\АСУ\Stackoverflow\split_log


Mode                LastWriteTime     Length Name
----                -------------     ------ ----
-a---        17.12.2018      6:03   10959355 1124.sql
-a---        17.12.2018      7:50    2461667 1124.sql_1.out
-a---        17.12.2018      7:50    2461458 1124.sql_2.out
-a---        17.12.2018      7:50    2461340 1124.sql_3.out
-a---        17.12.2018      7:50    2461352 1124.sql_4.out
-a---        17.12.2018      7:50    1113540 1124.sql_5.out
-a---        17.12.2018      7:27        357 split_log.ps1
Dmitry Demin
  • 2,006
  • 2
  • 15
  • 18
  • I’m new to PowerShell.... I have the text file on my Desktop and I want to split the files in a way the header also populates. Could you help me with the code? – Shabeen Zarook Dec 15 '18 at 08:23