Jump to content
UBot Underground

[GET] Split a CSV File Into Multiple


Recommended Posts

This is a script that I made to take a csv file and break it down into smaller files.

 

ui open file("Open CSV to Break:", #Open CSV)
ui text box("No. Rows Per file", #rows per file)
ui text box("Folder name:", #Folder name)
clear list(%rows)
clear table(&my files)
create table from file(#Open CSV, &my files)
set(#row in use, 0, "Global")
set(#master count, 0, "Global")
set(#chunk row, 0, "Global")
set(#chunk column, 0, "Global")
create folder($special folder("Application"), #Folder name)
clear table(&save chunk)
loop($table total rows(&my files)) {
increment(#master count)
set(#column in use, 0, "Global")
clear list(%rows)
loop($table total columns(&my files)) {
 set(#next row, $table cell(&my files, #row in use, #column in use), "Global")
 add item to list(%rows, #next row, "Delete", "Global")
 increment(#column in use)
}
increment(#row in use)
add list to table as row(&save chunk, #chunk row, 0, %rows)
if($comparison(#master count, ">=", #rows per file)) {
 then {
	 save to file("{$special folder("Application")}\\{#Folder name}\\{$random text(7)}.csv", &save chunk)
	 clear table(&save chunk)
	 set(#chunk row, 0, "Global")
	 set(#chunk column, 0, "Global")
	 set(#master count, 0, "Global")
 }
 else {
	 increment(#chunk row)
	 increment(#chunk column)
 }
}
}
if($comparison(#master count, "=", 0)) {
then {
}
else {
 save to file("{$special folder("Application")}\\{#Folder name}\\{$random text(7)}.csv", &save chunk)
}
}

  • Like 3
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...