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
#1
Hi,

I need to get rid of " from a JSON file

I have a JSON file like this:

{
    "type": "FeatureCollection",
    "features": [
        {
            "type": "Feature",
            "properties": {
                "Ville": "OZAN"
            },
            "geometry": {
                "type": "Point",
                "coordinates": [
                    "4.91667, 46.3833"
                ]
            }
        },
        {
            "type": "Feature",
            "properties": {
                "Ville": "CORMORANCHE-SUR-SAONE"
            },
            "geometry": {
                "type": "Point",
                "coordinates": [
                    "4.83333, 46.2333"
                ]
            }
        },
I need to remove the " before and after the coordinates in order to get this.

{
    "type": "FeatureCollection",
    "features": [
        {
            "type": "Feature",
            "properties": {
                "Ville": "OZAN"
            },
            "geometry": {
                "type": "Point",
                "coordinates": [
                    4.91667, 46.3833
                ]
            }
        },
        {
            "type": "Feature",
            "properties": {
                "Ville": "CORMORANCHE-SUR-SAONE"
            },
            "geometry": {
                "type": "Point",
                "coordinates": [
                    4.83333, 46.2333
                ]
            }
        },
I can't do it manually because i about 35k cities.

I can't find any viable solution, because I can't get rid of all the " from my file and i can't convert coordniates into float directly because of the [] .. such as this solution : https://stackoverflow.com/questions/3667...rom-python

Do you have any idea ? thank you in advance.
Reply


Messages In This Thread
Indirectlty convert string to float in JSON file - by WBPYTHON - May-05-2020, 01:51 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Parse Nested JSON String in Python rwalde 4 5,527 Sep-08-2022, 10:32 AM
Last Post: rwalde
Sad ValueError: could not convert string to float badju 0 5,566 Jul-01-2021, 12:13 AM
Last Post: badju
  HELP! Importing json file into csv into jupyter notebook vilsef 2 3,541 Jan-22-2021, 11:06 AM
Last Post: snippsat
  JSON file Loading issue punna111 4 10,774 Jun-29-2020, 08:07 AM
Last Post: buran
  ValueError: could not convert string to float RahulSingh 3 5,551 Apr-09-2020, 02:59 PM
Last Post: dinesh
  convert a list of string+bytes into a list of strings (python 3) pacscaloupsu 4 13,467 Mar-17-2020, 07:21 AM
Last Post: markfilan
  Help batch converting .json chosen file to MySQL BrandonKastning 2 3,126 Mar-14-2020, 09:19 PM
Last Post: BrandonKastning
  Convert dataframe string column to numeric in Python darpInd 1 3,061 Mar-14-2020, 10:07 AM
Last Post: ndc85430
  convert 'A B C' to numpy float matrix rezabma 4 3,845 Feb-27-2020, 09:48 AM
Last Post: rezabma
  ValueError: could not convert string to float: '4 AVENUE' Kudzo 4 7,742 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