Python Forum
Indirectlty convert string to float in JSON file
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Indirectlty convert string to float in JSON file
#2
1. load the json into json_data
2. iterate over features in json_data['features']
3. read the feature['geometry']['coordinates'][0] - this will give you a string, e.g."4.91667, 46.3833"
4. convert coordinates by splitting at comma, then convert individual values to float
5. assign coordinates from 4 as list to feature['geometry']['coordinates']
6. dump json data back to a file
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
RE: Indirectlty convert string to float in JSON file - by buran - May-05-2020, 02:36 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Parse Nested JSON String in Python rwalde 4 3,072 Sep-08-2022, 10:32 AM
Last Post: rwalde
Sad ValueError: could not convert string to float badju 0 4,369 Jul-01-2021, 12:13 AM
Last Post: badju
  HELP! Importing json file into csv into jupyter notebook vilsef 2 2,634 Jan-22-2021, 11:06 AM
Last Post: snippsat
  JSON file Loading issue punna111 4 8,700 Jun-29-2020, 08:07 AM
Last Post: buran
  ValueError: could not convert string to float RahulSingh 3 4,293 Apr-09-2020, 02:59 PM
Last Post: dinesh
  convert a list of string+bytes into a list of strings (python 3) pacscaloupsu 4 10,961 Mar-17-2020, 07:21 AM
Last Post: markfilan
  Help batch converting .json chosen file to MySQL BrandonKastning 2 2,390 Mar-14-2020, 09:19 PM
Last Post: BrandonKastning
  Convert dataframe string column to numeric in Python darpInd 1 2,338 Mar-14-2020, 10:07 AM
Last Post: ndc85430
  convert 'A B C' to numpy float matrix rezabma 4 2,610 Feb-27-2020, 09:48 AM
Last Post: rezabma
  ValueError: could not convert string to float: '4 AVENUE' Kudzo 4 6,020 Jan-26-2020, 10:47 PM
Last Post: Kudzo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020