This works great! Anyone that’s not used Sublime Text and is new and trying to goof around with data sets should check this out.
In the find and replace command (Cntrl+H) put these in Find:
^\n = remove an empty row in a data set
0 1 2
3 4 5
6 7 8
Becomes
0 1 2
3 4 5
6 7 8
\s = remove empty white space in say a float or int array
0, 1, 2, 3.14
Becomes
0,1,2,3.14
\s+ = format a string sentence and have 1 space only between words (in replace field just keyboard 1 space)
This and that. Plus this.
This and that. Plus this.
From: maya...@googlegroups.com [mailto:maya...@googlegroups.com] On Behalf Of Nathan Shipley
Sent: Sunday, May 23, 2021 1:36 PM
To: maya...@googlegroups.com
Subject: Re: [maya_he3d] Replace empty space from txt files
+1 to Sublime Text for tasks like this. You can search/replace with regular expressions, so this post, for examples shows a way:
I frequently use it to convert text on separate lines to a comma-separated, for example. Also the ability to use multiple cursors at the same time is really useful.
On Sun, May 23, 2021 at 2:12 PM Anthony Enos <antho...@gmail.com> wrote:
Not sure if/how directly in Mel, but I think you can remove them with a find/replace using Sublime text (free, great text editor). Pretty good search/replace features, even on multiple files at the same time. That’s my best guess without it in front of me.
On May 23, 2021, at 10:57 AM, bobrobertuma <bobrob...@gmail.com> wrote:
Hey all, how using mel, would I take an array like this that comes from Excel file that’s copied into notepad etc?
30 34 0
9 pCube1, 0, 0, 0, 0, 0, 0, 1, 1, 1
Etc.
string $array_mixed[] = {30 34 0 9 pCube1, 0, 0, 0, 0, 0, 0, 1, 1, 1 };
and format it to be {30, 34, 0, 9, pCube1, 0, 0, 0, 0, 0, 0, 1, 1, 1}
In other words I don’t see how to remove tab and empty space using commands “strip” “tokenize” “substituteAllString” and my mel is very spotty.
Jason
--
You received this message because you are subscribed to the Google Groups "maya_he3d" group.
To unsubscribe from this group and stop receiving emails from it, send an email to maya_he3d+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/maya_he3d/001401d74ffd%2415015cd0%243f041670%24%40gmail.com.--
You received this message because you are subscribed to the Google Groups "maya_he3d" group.
To unsubscribe from this group and stop receiving emails from it, send an email to maya_he3d+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/maya_he3d/D3EA82E0-E263-4487-835C-2BD006D017BB%40gmail.com.
--
You received this message because you are subscribed to the Google Groups "maya_he3d" group.
To unsubscribe from this group and stop receiving emails from it, send an email to maya_he3d+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/maya_he3d/CAMtaTCxuFuDXT1xjHZ23R4TNt_MCuKAwsc-ja_ovcpiuZq%2BNrg%40mail.gmail.com.
{
string $text_input ="30 34 0 9 pCube1, 0, 0, 0, 0, 0, 0, 1, 1, 1";
string $output[];
// split the string into separate items in an array
tokenize ($text_input , " ", $output);
print $output;
string $joined_string;
// put those items back together in a string
for ($each in $output)
{
print $each ;
print "\n";
string $anotherString[];
// split the indivdual string items into separte items to remove any existing commas
tokenize ($each, "," ,$anotherString);
string $newOutput = $anotherString[0];
// add the new string to the output string, with comma separation.
$joined_string += ($newOutput + ",");
}
print ( $joined_string + "\n");
}
myTest = "30 34 0 9 pCube1, 0, 0, 0, 0, 0, 0, 1, 1, 1"
# split the string by white space
output = myTest.split(" ")
print output
mydict = []
# iterate through the array, and clean out the commas
for e in output:
# check for white space , only use if has actual value.
if len(e) >= 1:
no_comma = e.replace(",","")
mydict.append(no_comma)
print mydict
# join the array back into a string for output
printOut = ",".join(mydict)
print printOut
To view this discussion on the web visit https://groups.google.com/d/msgid/maya_he3d/00a801d750b6%24f94e30c0%24ebea9240%24%40gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/maya_he3d/CAASZO1cvA68Usg2J4QtQcS_vikgT8X_KPoV1crijaE-Tx8ixVQ%40mail.gmail.com.