Example.gh (11.0 KB)
Hi im a bit stuck with converting text into a usable set of data.
Problem is the input generates a multiline data.
but i want to covert it in a list for each row.
Added picture shows the preferred output.
at the bottum ive added some blocks which i think would help me get there after i get the first step done
diff-arch
(diff-arch)
July 5, 2022, 10:38am
2
By default, Split separates with the whitespace character (e.g. " "). You want to use a newline character (e.g. “\n”) instead.
1 Like
any 1 has a tip for converting the first text pannel into the secund pannel?
could you upload the .gh file?
ah i see, thats why i wasnt getting the same output you ware showing.
i thought you placed the split on the first pannel.
this is an output i get from a program, which ware im currently stuck at.
from getting that data to be converted into lines like the pannel next to it.
kev.r
(Kevin)
July 5, 2022, 9:35pm
8
Use the Text Split component. Connect a Panel containing one newline character to the Separators (C) input.
Drop a Panel on the canvas.
Double-click to edit.
Press enter one time.
Click the ok button.
You get an extra item at the end of the output list because your input text contains an extra newline character at the end. You can correct this by using the Text Trim component:
-Kevin
1 Like
ok thanks, not sure why my output is different then yours but i can cull the empty fields and get the same result.
kev.r
(Kevin)
July 6, 2022, 9:13am
10
Not sure why you’re getting the empty lines. I was using the file you posted at the top of the thread.
I just re-downloaded your file it and I still don’t get those empty lines:
Example_re.gh (11.1 KB)
-Kevin
wierd enoff when i open your gh, i also get the empty output.
mybe it has to do with an older version of rhino7? → older gh version?
kev.r
(Kevin)
July 6, 2022, 9:38am
12
That is strange. I am running the latest service release candidate.
Rhino 7 SR20 2022-6-27 (Rhino 7, 7.20.22178.01002).
I am on MacOS. Perhaps it’s a Mac / Windows difference?
-Kevin
im not running the latest version of rhino so it might be on my end
thanks for the help
diff-arch
(diff-arch)
July 6, 2022, 10:57am
14
Try “\r” instead of “\n”. Maybe that will do the trick.
I’m on macOS, too.
kev.r
(Kevin)
July 6, 2022, 12:53pm
15
The problem is the way the Panel component handles text.
Here’s the results I get when I enter a single newline in a Panel using this method:
Drop a Panel on the canvas.
Double-click to edit.
Press enter one time.
Click the ok button.
On MacOs, I get this. Everything looks ok, the text is split correctly:
On Windows, I get this. The split text has extra empty lines and you can see from the python script that the panel is outputting “\r\n”
When I enter “\n” in a Panel I get this result on both Windows and MacOS. The Panel is outputting the literal characters (not escaping them). You can see that the text splits at the n character:
This works on both MacOS and Windows.
A python script with a single line of code.
a = "\n"
I did some searching and didn’t come up with any recommended methods to escape special characters in grasshopper.
-Kevin
1 Like
diff-arch
(diff-arch)
July 6, 2022, 1:19pm
16
Here’s an example where it’s all done with Python:
Example_re-rev.gh (10.7 KB)
1 Like