Tag: json

python json error: ValueError: Ожидающее значение: строка 1 столбец 1 (char 0)

Я из Кореи, поэтому, возможно, вы не понимаете ясно. У меня проблема с загрузкой json-файла через python. with open("D:/twitter/salathe-us-twitter/20110312/SB_DATA_SB/tweets.txt.2011-03-12_01", encoding='UTF8') as f: for line in f: temp = line.partition('|') date.append(temp[0]) # date tweets_data.append(temp[2]) Вот мой код на Python. Я разделяю строку, потому что есть некоторые ошибки. Темп выглядит так: ('20110302141002236', '|', '{"user":{"following":null,"profile_background_image_url":"http:\\/\\/a3.twimg.com\\/profile_background_images\\/141128439\\/2010-07-01_15.33.10.jpg","favourites_count":1,"verified":false,"time_zone":"Pacific Time (US & […]

Итерация через json-канал в python

Я повторяю через такой фид: {"siri":{"serviceDelivery":{"responseTimestamp":"2017-03-14T18:37:23Z","producerRef":"IVTR_RELAIS","status":"true","estimatedTimetableDelivery":[ {"lineRef":{"value":"C01742"},"directionRef":{"value":""},"datedVehicleJourneyRef":{"value":"SNCF-ACCES:VehicleJourney::UPAL97_20170314:LOC"},"vehicleMode":["RAIL"],"routeRef":{},"publishedLineName":[{"value":"RER A"}],"directionName":[],"originRef":{},"originName":[],"originShortName":[],"destinationDisplayAtOrigin":[],"via":[],"destinationRef":{"value":"STIF:StopPoint:Q:40918:"},"destinationName":[{"value":"GARE DE CERGY LE HAUT"}],"destinationShortName":[],"originDisplayAtDestination":[],"operatorRef":{"value":"SNCF-ACCES:Operator::SNCF:"},"productCategoryRef":{},"vehicleJourneyName":[],"journeyNote":[],"firstOrLastJourney":"UNSPECIFIED","additionalVehicleJourneyRef":[],"estimatedCalls":{"estimatedCall":[{"stopPointRef":{"value":"STIF:StopPoint:Q:411321:"},"expectedArrivalTime":"2017-03-14T20:02:00.000Z","expectedDepartureTime":"2017-03-14T20:02:00.000Z","aimedArrivalTime":"2017-03-14T20:02:00.000Z","aimedDepartureTime":"2017-03-14T20:02:00.000Z","stopPointName":[],"originDisplay":[],"destinationDisplay":[],"arrivalOperatorRefs":[]},{"stopPointRef":{"value":"STIF:StopPoint:Q:411368:"},"expectedArrivalTime":"2017-03-14T20:09:00.000Z","expectedDepartureTime":"2017-03-14T20:09:00.000Z","aimedArrivalTime":"2017-03-14T20:09:00.000Z","aimedDepartureTime":"2017-03-14T20:09:00.000Z","stopPointName":[],"originDisplay":[],"destinationDisplay":[],"arrivalOperatorRefs":[]},{"stopPointRef":{"value":"STIF:StopPoint:Q:411352:"},"expectedArrivalTime":"2017-03-14T20:05:00.000Z","expectedDepartureTime":"2017-03-14T20:05:00.000Z","aimedArrivalTime":"2017-03-14T20:05:00.000Z","aimedDepartureTime":"2017-03-14T20:05:00.000Z","stopPointName":[],"originDisplay":[],"destinationDisplay":[],"arrivalOperatorRefs":[]},{"stopPointRef":{"value":"STIF:StopPoint:Q:41528:"},"expectedArrivalTime":"2017-03-14T19:56:00.000Z","expectedDepartureTime":"2017-03-14T19:56:00.000Z","aimedArrivalTime":"2017-03-14T19:56:00.000Z","aimedDepartureTime":"2017-03-14T19:56:00.000Z","stopPointName":[],"originDisplay":[],"destinationDisplay":[],"arrivalOperatorRefs":[]},{"stopPointRef":{"value":"STIF:StopPoint:Q:40918:"},"expectedArrivalTime":"2017-03-14T20:12:00.000Z","aimedArrivalTime":"2017-03-14T20:12:00.000Z","aimedDepartureTime":"2017-03-14T20:12:00.000Z","stopPointName":[],"originDisplay":[],"destinationDisplay":[],"arrivalOperatorRefs":[]}]},"recordedAtTime":"2017-03-14T18:37:12.314Z"} ,{"lineRef":{"value":"C00049"},"directionRef":{"value":""},"datedVehicleJourneyRef":{"value":"004_DEVILLAIRS:VehicleJourney::109173051020957:LOC"},"vehicleMode":[],"routeRef":{},"publishedLineName":[{"value":"42"}],"directionName":[{"value":"Aller"}],"originRef":{},"originName":[],"originShortName":[],"destinationDisplayAtOrigin":[],"via":[],"destinationRef":{"value":"STIF:StopPoint:BP:12689:"},"destinationName":[{"value":"L'Onde Maison des Arts"}],"destinationShortName":[],"originDisplayAtDestination":[],"operatorRef":{"value":"004_DEVILLAIRS:Operator::004_DEVILLAIRS_Operator__004_DEVILLAIRS_Company__Devillairs 4_LOC_:"},"productCategoryRef":{},"vehicleJourneyName":[],"journeyNote":[],"firstOrLastJourney":"UNSPECIFIED","additionalVehicleJourneyRef":[],"estimatedCalls":{"estimatedCall":[{"stopPointRef":{"value":"STIF:StopPoint:Q:12690:"},"expectedArrivalTime":"2017-03-14T18:44:26.000Z","expectedDepartureTime":"2017-03-14T18:44:26.000Z","aimedArrivalTime":"2017-03-14T18:43:39.000Z","aimedDepartureTime":"2017-03-14T18:43:39.000Z","stopPointName":[],"originDisplay":[],"destinationDisplay":[],"arrivalOperatorRefs":[]},{"stopPointRef":{"value":"STIF:StopPoint:Q:12684:"},"expectedArrivalTime":"2017-03-14T18:38:51.000Z","expectedDepartureTime":"2017-03-14T18:38:51.000Z","aimedArrivalTime":"2017-03-14T18:34:51.000Z","aimedDepartureTime":"2017-03-14T18:34:51.000Z","stopPointName":[],"originDisplay":[],"destinationDisplay":[],"arrivalOperatorRefs":[]},{"stopPointRef":{"value":"STIF:StopPoint:Q:40538:"},"expectedArrivalTime":"2017-03-14T18:40:53.000Z","expectedDepartureTime":"2017-03-14T18:40:53.000Z","aimedArrivalTime":"2017-03-14T18:37:24.000Z","aimedDepartureTime":"2017-03-14T18:37:24.000Z","stopPointName":[],"originDisplay":[],"destinationDisplay":[],"arrivalOperatorRefs":[]},{"stopPointRef":{"value":"STIF:StopPoint:Q:12678:"},"expectedArrivalTime":"2017-03-14T18:41:10.000Z","expectedDepartureTime":"2017-03-14T18:41:10.000Z","aimedArrivalTime":"2017-03-14T18:37:57.000Z","aimedDepartureTime":"2017-03-14T18:37:57.000Z","stopPointName":[],"originDisplay":[],"destinationDisplay":[],"arrivalOperatorRefs":[]},{"stopPointRef":{"value":"STIF:StopPoint:Q:12682:"},"expectedArrivalTime":"2017-03-14T18:40:00.000Z","expectedDepartureTime":"2017-03-14T18:40:00.000Z","aimedArrivalTime":"2017-03-14T18:36:21.000Z","aimedDepartureTime":"2017-03-14T18:36:21.000Z","stopPointName":[],"originDisplay":[],"destinationDisplay":[],"arrivalOperatorRefs":[]},{"stopPointRef":{"value":"STIF:StopPoint:Q:41690:"},"expectedArrivalTime":"2017-03-14T18:42:17.000Z","expectedDepartureTime":"2017-03-14T18:42:17.000Z","aimedArrivalTime":"2017-03-14T18:39:00.000Z","aimedDepartureTime":"2017-03-14T18:39:00.000Z","stopPointName":[],"originDisplay":[],"destinationDisplay":[],"arrivalOperatorRefs":[]},{"stopPointRef":{"value":"STIF:StopPoint:Q:12743:"},"expectedDepartureTime":"2017-03-14T18:15:00.000Z","aimedDepartureTime":"2017-03-14T18:15:00.000Z","stopPointName":[],"originDisplay":[],"destinationDisplay":[],"arrivalOperatorRefs":[]},{"stopPointRef":{"value":"STIF:StopPoint:Q:12680:"},"expectedArrivalTime":"2017-03-14T18:40:24.000Z","expectedDepartureTime":"2017-03-14T18:40:24.000Z","aimedArrivalTime":"2017-03-14T18:36:52.000Z","aimedDepartureTime":"2017-03-14T18:36:52.000Z","stopPointName":[],"originDisplay":[],"destinationDisplay":[],"arrivalOperatorRefs":[]},{"stopPointRef":{"value":"STIF:StopPoint:Q:12676:"},"expectedArrivalTime":"2017-03-14T18:41:42.000Z","expectedDepartureTime":"2017-03-14T18:41:42.000Z","aimedArrivalTime":"2017-03-14T18:38:29.000Z","aimedDepartureTime":"2017-03-14T18:38:29.000Z","stopPointName":[],"originDisplay":[],"destinationDisplay":[],"arrivalOperatorRefs":[]}]},"recordedAtTime":"2017-03-14T18:35:51.000Z"} ,{"lineRef":{"value":"C01375"},"directionRef":{"value":""},"datedVehicleJourneyRef":{"value":"RATP:VehicleJourney::M5.R.1937.1:LOC"},"vehicleMode":[],"routeRef":{},"publishedLineName":[{"value":"Place d'Italie / Bobigny Pablo Picasso"}],"directionName":[{"value":"Bobigny Pablo Picasso"}],"originRef":{},"originName":[],"originShortName":[],"destinationDisplayAtOrigin":[],"via":[],"destinationRef":{"value":"STIF:StopPoint:Q:22015:"},"destinationName":[{"value":"Bobigny Pablo Picasso"}],"destinationShortName":[],"originDisplayAtDestination":[],"operatorRef":{},"productCategoryRef":{},"vehicleJourneyName":[],"journeyNote":[],"firstOrLastJourney":"UNSPECIFIED","additionalVehicleJourneyRef":[],"estimatedCalls":{"estimatedCall":[{"stopPointRef":{"value":"STIF:StopPoint:Q:22003:"},"expectedDepartureTime":"2017-03-14T18:37:00.000Z","stopPointName":[],"originDisplay":[],"destinationDisplay":[],"arrivalOperatorRefs":[]},{"stopPointRef":{"value":"STIF:StopPoint:Q:22008:"},"expectedDepartureTime":"2017-03-14T18:37:00.000Z","stopPointName":[],"originDisplay":[],"destinationDisplay":[],"arrivalOperatorRefs":[]},{"stopPointRef":{"value":"STIF:StopPoint:Q:22017:"},"expectedDepartureTime":"2017-03-14T18:37:00.000Z","stopPointName":[],"originDisplay":[],"destinationDisplay":[],"arrivalOperatorRefs":[]},{"stopPointRef":{"value":"STIF:StopPoint:Q:21952:"},"expectedDepartureTime":"2017-03-14T18:37:00.000Z","stopPointName":[],"originDisplay":[],"destinationDisplay":[],"arrivalOperatorRefs":[]},{"stopPointRef":{"value":"STIF:StopPoint:Q:22009:"},"expectedDepartureTime":"2017-03-14T18:37:00.000Z","stopPointName":[],"originDisplay":[],"destinationDisplay":[],"arrivalOperatorRefs":[]},{"stopPointRef":{"value":"STIF:StopPoint:Q:22016:"},"expectedDepartureTime":"2017-03-14T18:37:00.000Z","stopPointName":[],"originDisplay":[],"destinationDisplay":[],"arrivalOperatorRefs":[]},{"stopPointRef":{"value":"STIF:StopPoint:Q:22007:"},"expectedDepartureTime":"2017-03-14T18:37:00.000Z","stopPointName":[],"originDisplay":[],"destinationDisplay":[],"arrivalOperatorRefs":[]},{"stopPointRef":{"value":"STIF:StopPoint:Q:21903:"},"expectedDepartureTime":"2017-03-14T18:37:00.000Z","stopPointName":[],"originDisplay":[],"destinationDisplay":[],"arrivalOperatorRefs":[]},{"stopPointRef":{"value":"STIF:StopPoint:Q:22005:"},"expectedDepartureTime":"2017-03-14T18:37:00.000Z","stopPointName":[],"originDisplay":[],"destinationDisplay":[],"arrivalOperatorRefs":[]},{"stopPointRef":{"value":"STIF:StopPoint:Q:22006:"},"expectedDepartureTime":"2017-03-14T18:37:00.000Z","stopPointName":[],"originDisplay":[],"destinationDisplay":[],"arrivalOperatorRefs":[]},{"stopPointRef":{"value":"STIF:StopPoint:Q:22004:"},"expectedDepartureTime":"2017-03-14T18:37:00.000Z","stopPointName":[],"originDisplay":[],"destinationDisplay":[],"arrivalOperatorRefs":[]},{"stopPointRef":{"value":"STIF:StopPoint:Q:22012:"},"expectedDepartureTime":"2017-03-14T18:37:00.000Z","stopPointName":[],"originDisplay":[],"destinationDisplay":[],"arrivalOperatorRefs":[]},{"stopPointRef":{"value":"STIF:StopPoint:Q:22011:"},"expectedDepartureTime":"2017-03-14T18:37:00.000Z","stopPointName":[],"originDisplay":[],"destinationDisplay":[],"arrivalOperatorRefs":[]},{"stopPointRef":{"value":"STIF:StopPoint:Q:22013:"},"expectedDepartureTime":"2017-03-14T18:37:00.000Z","stopPointName":[],"originDisplay":[],"destinationDisplay":[],"arrivalOperatorRefs":[]},{"stopPointRef":{"value":"STIF:StopPoint:Q:21981:"},"expectedDepartureTime":"2017-03-14T18:37:00.000Z","stopPointName":[],"originDisplay":[],"destinationDisplay":[],"arrivalOperatorRefs":[]},{"stopPointRef":{"value":"STIF:StopPoint:Q:22000:"},"expectedDepartureTime":"2017-03-14T18:37:00.000Z","stopPointName":[],"originDisplay":[],"destinationDisplay":[],"arrivalOperatorRefs":[]},{"stopPointRef":{"value":"STIF:StopPoint:Q:22010:"},"expectedDepartureTime":"2017-03-14T18:37:00.000Z","stopPointName":[],"originDisplay":[],"destinationDisplay":[],"arrivalOperatorRefs":[]},{"stopPointRef":{"value":"STIF:StopPoint:Q:22002:"},"expectedDepartureTime":"2017-03-14T18:37:00.000Z","stopPointName":[],"originDisplay":[],"destinationDisplay":[],"arrivalOperatorRefs":[]},{"stopPointRef":{"value":"STIF:StopPoint:Q:22001:"},"expectedDepartureTime":"2017-03-14T18:37:00.000Z","stopPointName":[],"originDisplay":[],"destinationDisplay":[],"arrivalOperatorRefs":[]}]},"recordedAtTime":"2017-03-14T18:36:55.890Z"} ,{"lineRef":{"value":"C00774"},"directionRef":{"value":""},"datedVehicleJourneyRef":{"value":"STIVO:VehicleJourney::268437511:LOC"},"vehicleMode":[],"routeRef":{},"publishedLineName":[{"value":"CERGY PREFECTURE-VAUREAL TOUPETS"}],"directionName":[{"value":"R"}],"originRef":{},"originName":[],"originShortName":[],"destinationDisplayAtOrigin":[],"via":[],"destinationRef":{"value":"STIF:StopPoint:Q:10118:"},"destinationName":[{"value":"Préfecture RER"}],"destinationShortName":[],"originDisplayAtDestination":[],"operatorRef":{},"productCategoryRef":{},"vehicleJourneyName":[],"journeyNote":[],"firstOrLastJourney":"UNSPECIFIED","additionalVehicleJourneyRef":[],"estimatedCalls":{"estimatedCall":[{"stopPointRef":{"value":"STIF:StopPoint:Q:8729:"},"expectedDepartureTime":"2017-03-14T18:39:31.000Z","aimedDepartureTime":"2017-03-14T18:39:00.000Z","stopPointName":[],"originDisplay":[],"destinationDisplay":[],"arrivalOperatorRefs":[]},{"stopPointRef":{"value":"STIF:StopPoint:Q:8731:"},"expectedDepartureTime":"2017-03-14T18:40:31.000Z","aimedDepartureTime":"2017-03-14T18:40:20.000Z","stopPointName":[],"originDisplay":[],"destinationDisplay":[],"arrivalOperatorRefs":[]},{"stopPointRef":{"value":"STIF:StopPoint:Q:8730:"},"expectedDepartureTime":"2017-03-14T18:40:46.000Z","aimedDepartureTime":"2017-03-14T18:39:51.000Z","stopPointName":[],"originDisplay":[],"destinationDisplay":[],"arrivalOperatorRefs":[]}]},"recordedAtTime":"2017-03-14T18:36:43.000Z"} ,{"lineRef":{"value":"C00697"},"directionRef":{"value":""},"datedVehicleJourneyRef":{"value":"SRVSAE:VehicleJourney::34661-1:LOC"},"vehicleMode":["BUS"],"routeRef":{},"publishedLineName":[{"value":"H "}],"directionName":[],"originRef":{"value":"STIF:StopPoint:BP:20399:"},"originName":[{"value":"Versailles Rive Gauche"}],"originShortName":[],"destinationDisplayAtOrigin":[],"via":[],"destinationRef":{"value":"STIF:StopPoint:BP:4122:"},"destinationName":[{"value":"La Celle St Cloud – Gare"}],"destinationShortName":[],"originDisplayAtDestination":[],"operatorRef":{"value":"SRVSAE:Operator::56 :"},"productCategoryRef":{},"vehicleJourneyName":[{"value":"34661-1"}],"journeyNote":[],"firstOrLastJourney":"OTHER_SERVICE","additionalVehicleJourneyRef":[],"estimatedCalls":{"estimatedCall":[{"stopPointRef":{"value":"STIF:StopPoint:Q:4062:"},"expectedArrivalTime":"2017-03-14T18:39:55.000Z","expectedDepartureTime":"2017-03-14T18:39:55.000Z","aimedArrivalTime":"2017-03-14T18:35:00.000Z","aimedDepartureTime":"2017-03-14T18:35:00.000Z","stopPointName":[],"originDisplay":[],"destinationDisplay":[],"arrivalOperatorRefs":[]},{"stopPointRef":{"value":"STIF:StopPoint:Q:4064:"},"expectedArrivalTime":"2017-03-14T18:38:58.000Z","expectedDepartureTime":"2017-03-14T18:38:58.000Z","aimedArrivalTime":"2017-03-14T18:34:10.000Z","aimedDepartureTime":"2017-03-14T18:34:10.000Z","stopPointName":[],"originDisplay":[],"destinationDisplay":[],"arrivalOperatorRefs":[]},{"stopPointRef":{"value":"STIF:StopPoint:Q:4068:"},"expectedArrivalTime":"2017-03-14T18:36:48.000Z","expectedDepartureTime":"2017-03-14T18:36:48.000Z","aimedArrivalTime":"2017-03-14T18:32:00.000Z","aimedDepartureTime":"2017-03-14T18:32:00.000Z","stopPointName":[],"originDisplay":[],"destinationDisplay":[],"arrivalOperatorRefs":[]}]},"recordedAtTime":"2017-03-14T18:33:37.000Z"} ]}}} Использование скрипта python: import datetime import time import dateutil.parser import pytz import json […]

Как сохранить словарь объектов в Python?

У меня есть программа Python 3.5, которая создает инвентарь объектов. Я создал класс батутов (цвет, размер, весна и т. Д.). Я постоянно создаю новые экземпляры класса, а затем сохраняю их словарь. Словарь выглядит следующим образом: my_dict = {name: instance} and the types are like so {"string": "object"} МОЙ ВОПРОС – это то, что я хочу […]

Запись формата json с использованием pandas Series и DataFrame

Я работаю с csvfiles. Моя цель – написать json-формат с информацией csvfile. В частности, я хочу получить такой же формат, как miserables.json Пример: {"source": "Napoleon", "target": "Myriel", "value": 1}, Согласно информации, которую я имею, формат был бы: [ { "source": "Germany", "target": "Mexico", "value": 1 }, { "source": "Germany", "target": "USA", "value": 2 }, { […]

Попытка POST json-данных с Python на PHP

Я изменил http://fivefilters.org/term-extraction/ этот проект, чтобы: Учитывая ввод (https://gist.github.com/4426264) текста, скрипт python term-extraction.py выводит ключевые слова в формате json и отправляет через POST json в php-файл term-extraction.py -> echo.php link to term-extraction.py https://gist.github.com/4426181 ссылка на echo.php https://gist.github.com/4426193 здесь приведен json-выход, заданный скриптом php: https://gist.github.com/4426197 здесь выведено выражение term-extraction.py: http://jsfiddle.net/Bw7UX/ вот желаемый вывод массива, который я […]

Вставка реляционных данных в SQL Alchemy с запросами API в Python

Возможно, мой предыдущий вопрос был слишком длинным и бесконечным, чтобы ответить, извините за это … Я постараюсь более конкретно сократить свой предыдущий вопрос Я могу извлечь из запроса API (формат json в качестве вывода) следующую информацию: GENE1 Experiment1 Experiment2 Experiment3 Experiment4 GENE2 Experiment5 Experiment2 Experiment3 Experiment8 Experiment9 […] Поэтому я получаю гены и связанные с […]

несколько json словарей python

У меня есть json-файл с несколькими json-словарями: формат выглядит следующим образом {"x":"1", "y":"2", "z": "3"}{"x": "2","y":"3", "z":"4"}{"x":"3", "y":"4", "z":"5"} Как я могу преобразовать это в один формат словаря json следующим образом: {"items":[{"x":"1", "y":"2", "z": "3"},{"x": "2","y":"3", "z":"4"},{"x":"3", "y":"4", "z":"5"}]}

повысить ImgurClientError («JSON-декодирование ответа не удалось».) imgurpython.helpers.error.ImgurClientError: JSON-декодирование ответа не удалось

Для кода ниже: 12 imgur_client = ImgurClient(client_id, client_secret, access_token, refresh_token) 13 for p in range(100, 500): 14 search = imgur_client.gallery_search('cat', window='all', sort='time', page=p) 15 for i in range(0, len(search)): 16 #print(search[i].link) 17 #print(dir(search[i])) 18 print(search[i].type) 19 if search[i].comment_count > 30 and search[i].type!='gif': 20 count = 0 21 image_file = urllib2.urlopen(search[i].link, timeout = 5) 22 image_file_name […]

Импорт данных JSON в Django View / Template

Таким образом, я работаю над проектом и im, используя json-данные из графитового графика и im, пытаясь импортировать его в файл django views.py, а затем получить значение, которое я хочу в шаблоне. Импорт будет происходить из удаленного URL-адреса, а не непосредственно непосредственно на сервере. вот мой json: [{"target": "stocks.shared (last: 4204.0)", "datapoints": [[4379.0, 1389225600], [4204.0, 1389312000]]}] […]

сортировка вывода файла python по местоположению. прирост по общему id

Есть несколько экземпляров данных, которые имеют одинаковые идентификаторы местоположения, например, на выходе ниже есть много 3 с: 121 {'data': {'id': 3, 'type': 'location'}, 'links': {'self': 'http://localhost:2510/api/v2/jobs/121/location'}} 122 {'data': {'id': 3, 'type': 'location'}, 'links': {'self': 'http://localhost:2510/api/v2/jobs/122/location'}} 120 {'data': {'id': 3, 'type': 'location'}, 'links': {'self': 'http://localhost:2510/api/v2/jobs/120/location'}} 119 {'data': {'id': 3, 'type': 'location'}, 'links': {'self': 'http://localhost:2510/api/v2/jobs/119/location'}} 191 {'data': […]

Python - лучший язык программирования в мире.