Extract Json (Polygon.PointsFromString) Data in a txt file

i do have a txt file with json date and i do not know how to read them and put them into a list

ListOfPolygons.txt (516 Bytes)

this code do not work

text2

Not sure what you are attempting Franck.

You might try this:

1,"[[10.22054,-83.59250],[10.22088,-83.59176],[10.22054,-83.59156],[10.22019,-83.59232],[10.22054,-83.59250]]",Banano 2,2
2,"[[10.22018,-83.59230],[10.22012,-83.59162],[10.21998,-83.59188],[10.21979,-83.59181],[10.21968,-83.59202],[10.22018,-83.59230]]",Banano 1,1
3,"[[10.22055,-83.59151],[10.22053,-83.59151],[10.22055,-83.59151]]",Banano 3,3
4,"[[10.22032,-83.59058],[10.22032,-83.59058]]",Banano 4,4
5,"[[10.22050,-83.59075],[10.22034,-83.59067],[10.22029,-83.59076],[10.22046,-83.59085],[10.22050,-83.59075]]",Banano 5,2

where you encode your actual polygon points in " ". Coding this way might work.

Regards,
Steve

First method:

image

Your data file is not in standard JSON format (www.json.org)

If it were in standard JSON format, it would have [] around the inner lists, and they would be wrapped with [ …,…,…] for the outer JSON list layer.

It is also not a CSV format, because the inner commas are not shielded by “” marks.

I advise fixing the data source, otherwise you will have to write your own hybrid JSON/CSV parser.

Use the modified txt file I provided Frank and you can do this (but make sure your csv is a csv table …
1,"[[10.22054,-83.59250],[10.22088,-83.59176],[10.22054,-83.59156],[10.22019,-83.59232],[10.22054,-83.59250]]",Banano 2,2\n
2,"[[10.22018,-83.59230],[10.22012,-83.59162],[10.21998,-83.59188],[10.21979,-83.59181],[10.21968,-83.59202],[10.22018,-83.59230]]",Banano 1,1\n
3,"[[10.22055,-83.59151],[10.22053,-83.59151],[10.22055,-83.59151]]",Banano 3,3\n
4,"[[10.22032,-83.59058],[10.22032,-83.59058]]",Banano 4,4\n
5,"[[10.22050,-83.59075],[10.22034,-83.59067],[10.22029,-83.59076],[10.22046,-83.59085],[10.22050,-83.59075]]",Banano 5,2

to display your Polygons. A Polygon PointsFromString looks like this [[10.22054,-83.59250],[10.22088,-83.59176],[10.22054,-83.59156],[10.22019,-83.59232],[10.22054,-83.59250]]

The attached code extracts one of the Polygons and displays it on a Map component.

Edit: your 4th element ( 4,"[[10.22032,-83.59058],[10.22032,-83.59058]]",Banano 4,4) is NOT a polygon. Trying to display it will invoke an error. You have only two points; a polygon requires a minimum of THREE.

Currently you are able to display these:
display

Regards,
Steve

Second Method:

image

but as ABG says, reorganise your base data!