Difficulty importing tab delimited file into geogebra spreadsheet

wm shared this question 5 months ago
Answered

Hello,


I have a tab delimited text file. Please see attached. I would like to automatically "load" this file into geogebra spreadsheet.


The format of the file is:


Column A: xcoordinate of point1

B: ycoordinate of point1

C:point1

D: xcoordinate of point2

E:ycoordinate of point2

F:point2

G:segment connecting point1 and point2

H:label that should be displayed over segment constructed in G.


When I copy and paste this, all of these seem to be pasted as values in the spreadsheet. Is there a way to automatically get geogebra to construct these segments and label them via an import function of some sort?


Thanks.

Comments (9)

photo
1

the fields are not tab delimiter

to import with excel does not work also

photo
1

Is there a way a script can be written that given the following input in spreadsheet view:


Row1> Pt1x Pt1y Pt2x Pt2y labelsegment1

Row2> Pt1x Pt1y Pt2x Pt2y labelsegment2


constructs "=Segment( (Pt1x,Pt1y), (Pt2x,Pt2y) ) " for each row,


then displays the object, and then labels this object the appropriate label for that row -- all of these in the graphics view?


At present, the only option seems to be to copy paste the points across all rows, manually create a segment function in the top row, set its caption property to %c ensuring that the label is in the cell to the right and then drag this formula down all the rows. Is that right?

photo
1

if I understand well I think yes

you can not copy and paste the command segment from another spreadsheet because segment is text in other spreadsheets

you can copy and paste two pairs of columns with the coords of point from another spreadsheet and create segments for each row doing you say

photo
1

Please explain overall what you are trying to do - probably using the API will be easier

photo
1

Overall, what I am trying to do is that I have a C++ application that generates a sequence of (rows of) pairs of points {(x1,y1),(x2,y2)}. These are stored in a text file -- one line for each pairs of points -- i.e., each line will have five entries or columns x1, y1, x2, y2 and a fifth column containing a label for this segment. I would like to create a line segment connecting each of these pairs of points, display the resulting object (the points themselves need not be displayed/labelled) in the graphics view and label this segment using the entry of the fifth column.


The number of these can be around 20 or 30 -- large enough that it would benefit from some automation instead of manual typing,


In the file attached with my OP, you will see 8 columns instead of five. That is because I had tried to have my C++ application type out the exact geogebra command (see column 3 for instance which creates point1, and column 7 for instance which creates the line segment) that I would have had to enter in the spreadsheet view to get the display. However, as mentioned above, copying and pasting these from any outside application into geogebra spreadsheet view is not supported.

I would be grateful if any automated/script is possible to be generated that helps do the steps above.

Thank you for your help.

photo
2

format the text file like in this example of wordpad

/WhQf8bUeP50oE41J9ioukWnrnOreTxAQAAAIf4QVGl0bGU6CQlVbnRpdGxlZAA7

Then you can define segment(A1,B1),(C1,D1)) in F1, the drag&drop action will do the rest

photo
1

Thanks mathmagic.


That worked, with one change. The way that you present, having the "=segment()" function in f1 would not work since %c is setup to label from the cell on its right which in this case would be g1.


So, I had to do the following


1,2,3,4,,"label1"

5,6,7,8,,"label2"


Note blank fifth field. Then, in e1 (not f1), I entered "=segment((a1,b1),(c1,d1))", set its caption to %c and had it show caption label. This displays the segment.

Then, copy pasting the formula down replicated that for E2 as well.

photo
1

I know


%c is setup to label from the cell on its right

So, I had to do the following 

......or G1=E1

I give the trick and you adapt it to your show

photo
photo
1

Two other options


1) write directly to an XML file that GeoGebra can read (a bit tricky)

https://daveagp.wordpress.c...


2) Output GeoGebra Script, then paste into a button, eg

A1=1
B1=2
C1=(A1,B1)
D1=(3,4)
E1=Segment(C1,D1)
etc

© 2021 International GeoGebra Institute