SlideShare una empresa de Scribd logo
1 de 15
Descargar para leer sin conexión
 Basic NetworkX
› Adding node(s), edges(s) to a graph
› Drawing graphs
› Networks characteristics
 Degree distribution
› Creating network of Twitter
 Dictionaries – compound data type
 Found in other languages as “map”,
“associative memories”, or “associative arrays”
 Lists vs Dictionaries
› You can use only integer number as index on lists
Like a[0], a[-1]
› You can use integer numbers and strings as key on
dictionaries(if its value exists)
Like d[0], d[‘foo’], d[‘bar’]
 Creating a dictionary
tel = {‘John’:0000, ‘Jane’:0001, ‘Joe’:0002}
 Adding key and value
tel[‘Joan’] = 0003
 Getting value from key
tel[‘Jane’]
 Setting value from key
tel[‘Joe’] = 0004
 Removing value from key
del tel[‘John’]
 Getting key list of a dictionary
tel.keys()
 you can nest dictionaries, like
data = {‘one’: {‘one’: 11, ‘two’: 12}, ‘two’: {‘one’: 21, ‘two’: 22}}
print data[‘one’][‘two’]
 Also, you can combine lists and dictionaries, like
data = {‘employees’:[
{‘firstName’: ‘John’, ‘lastName’: ‘Doe’},
{‘firstName’: ‘Anna’, ‘lastName’: ‘Smith’},
{‘firstName’: ‘Peter’, ‘lastName’: ‘Jones’}
]
print data[‘employees’][2][‘firstName’]
 JSON (JavaScript Object Notation) is a
lightweight data-interchange format.
 It is easy for humans to read and write.
 It is easy for machines to parse and
generate.
From http://json.org/
 A collection of name/value pairs. In various
languages, this is realized as an object,
record, struct, dictionary, hash table, keyed
list, or associative array.
 An ordered list of values. In most languages,
this is realized as an array, vector, list, or
sequence.
 From http://json.org/
{"employees":[
{"firstName":"John", "lastName":"Doe"},
{"firstName":"Anna", "lastName":"Smith"},
{"firstName":"Peter", "lastName":"Jones"}
]}
Example from
http://www.w3schools.com/json/
import json
 Load json from raw string
data = json.loads(‘{"employees":[
{"firstName":"John", "lastName":"Doe"},
{"firstName":"Anna", "lastName":"Smith"},
{"firstName":"Peter", "lastName":"Jones"}
]}’
print data[‘employees’][2][‘firstName’]
 From json file(save previous json as sample.json)
with open(‘sample.json’, ‘r’) as f:
data = json.load(f)
print data[‘employees’][2][‘firstName’]
 From url
Import urllib2
data = json.load(urllib2.urlopen(‘http://time.jsontest.com’))
print ‘Today is’, data[‘date’]
 http://www.ebay.com/
 An online auction and shopping site
 HTTP GET URL(search items that its keyword is “harry potter phoenix”
http://svcs.ebay.com/services/search/FindingService/v1?
OPERATION-NAME=findItemsByKeywords
&SERVICE-VERSION=1.0.0
&SECURITY-APPNAME=YourAppID
&RESPONSE-DATA-FORMAT=json
&REST-PAYLOAD
&keywords=harry%20potter%20phoenix
 YourAppID have to be replaced
 More Information:
› http://developer.ebay.com/Devzone/finding/Concepts/MakingACall.html
› http://developer.ebay.com/Devzone/finding/CallRef/index.html
 https://github.com/
 An online software development
environment
 HTTP GET URL(searches repositories(projects) that its keyword
is “tetris” and written in assembly language)
https://api.github.com/search/repositories?
q=tetris+language:assembly
&sort=stars
&order=desc
 More information:
› https://developer.github.com/v3/
› https://developer.github.com/v3/search/
 Saving
import networkx as nx
import pickle
G = Graph()
# some works here
pickle.dump(G, open(‘your_graph.txt’, ‘w’))
 Loading
G = pickle.load(open(‘your_graph.txt’, ‘r’))
 Dictionaries(Python data structure)
 Brief explanation of JSON
 Getting JSON Data
› From raw string
› From JSON file
› From URL
 Example: eBay and GitHub
 Saving/loading networks

Más contenido relacionado

La actualidad más candente

Be Smart, Constrain Your Types to Free Your Brain!
Be Smart, Constrain Your Types to Free Your Brain!Be Smart, Constrain Your Types to Free Your Brain!
Be Smart, Constrain Your Types to Free Your Brain!Jorge Vásquez
 
Native json in the Cache' ObjectScript 2016.*
Native json in the Cache' ObjectScript 2016.*Native json in the Cache' ObjectScript 2016.*
Native json in the Cache' ObjectScript 2016.*Timur Safin
 
R- create a table from a list of files.... before webmining
R- create a table from a list of files.... before webminingR- create a table from a list of files.... before webmining
R- create a table from a list of files.... before webminingGabriela Plantie
 
MongoDB: Easy Java Persistence with Morphia
MongoDB: Easy Java Persistence with MorphiaMongoDB: Easy Java Persistence with Morphia
MongoDB: Easy Java Persistence with MorphiaScott Hernandez
 
9. Php MongoDB cautarea unui document
9. Php MongoDB cautarea unui document9. Php MongoDB cautarea unui document
9. Php MongoDB cautarea unui documentRazvan Raducanu, PhD
 
8. Php MongoDB stergerea unui document
8. Php MongoDB stergerea unui document8. Php MongoDB stergerea unui document
8. Php MongoDB stergerea unui documentRazvan Raducanu, PhD
 
A Game of Hierarchies - From GROUP BY to Recursive CTE
A Game of Hierarchies - From GROUP BY to Recursive CTEA Game of Hierarchies - From GROUP BY to Recursive CTE
A Game of Hierarchies - From GROUP BY to Recursive CTEMarkus Ehrenmueller-Jensen
 
7. Php MongoDB editarea unui document
7. Php MongoDB editarea unui document7. Php MongoDB editarea unui document
7. Php MongoDB editarea unui documentRazvan Raducanu, PhD
 
6. Php MongoDB adaugarea unui document
6. Php MongoDB adaugarea unui document6. Php MongoDB adaugarea unui document
6. Php MongoDB adaugarea unui documentRazvan Raducanu, PhD
 
Max Neunhöffer – Joins and aggregations in a distributed NoSQL DB - NoSQL mat...
Max Neunhöffer – Joins and aggregations in a distributed NoSQL DB - NoSQL mat...Max Neunhöffer – Joins and aggregations in a distributed NoSQL DB - NoSQL mat...
Max Neunhöffer – Joins and aggregations in a distributed NoSQL DB - NoSQL mat...NoSQLmatters
 

La actualidad más candente (16)

Be Smart, Constrain Your Types to Free Your Brain!
Be Smart, Constrain Your Types to Free Your Brain!Be Smart, Constrain Your Types to Free Your Brain!
Be Smart, Constrain Your Types to Free Your Brain!
 
04 standard class library c#
04 standard class library c#04 standard class library c#
04 standard class library c#
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
 
Native json in the Cache' ObjectScript 2016.*
Native json in the Cache' ObjectScript 2016.*Native json in the Cache' ObjectScript 2016.*
Native json in the Cache' ObjectScript 2016.*
 
R- create a table from a list of files.... before webmining
R- create a table from a list of files.... before webminingR- create a table from a list of files.... before webmining
R- create a table from a list of files.... before webmining
 
PHP - Introduction to File Handling with PHP
PHP -  Introduction to  File Handling with PHPPHP -  Introduction to  File Handling with PHP
PHP - Introduction to File Handling with PHP
 
MongoDB: Easy Java Persistence with Morphia
MongoDB: Easy Java Persistence with MorphiaMongoDB: Easy Java Persistence with Morphia
MongoDB: Easy Java Persistence with Morphia
 
9. Php MongoDB cautarea unui document
9. Php MongoDB cautarea unui document9. Php MongoDB cautarea unui document
9. Php MongoDB cautarea unui document
 
Json
JsonJson
Json
 
Php File Operations
Php File OperationsPhp File Operations
Php File Operations
 
8. Php MongoDB stergerea unui document
8. Php MongoDB stergerea unui document8. Php MongoDB stergerea unui document
8. Php MongoDB stergerea unui document
 
A Game of Hierarchies - From GROUP BY to Recursive CTE
A Game of Hierarchies - From GROUP BY to Recursive CTEA Game of Hierarchies - From GROUP BY to Recursive CTE
A Game of Hierarchies - From GROUP BY to Recursive CTE
 
7. Php MongoDB editarea unui document
7. Php MongoDB editarea unui document7. Php MongoDB editarea unui document
7. Php MongoDB editarea unui document
 
6. Php MongoDB adaugarea unui document
6. Php MongoDB adaugarea unui document6. Php MongoDB adaugarea unui document
6. Php MongoDB adaugarea unui document
 
Mongo db
Mongo dbMongo db
Mongo db
 
Max Neunhöffer – Joins and aggregations in a distributed NoSQL DB - NoSQL mat...
Max Neunhöffer – Joins and aggregations in a distributed NoSQL DB - NoSQL mat...Max Neunhöffer – Joins and aggregations in a distributed NoSQL DB - NoSQL mat...
Max Neunhöffer – Joins and aggregations in a distributed NoSQL DB - NoSQL mat...
 

Destacado

cambridgeshire_casestudy
cambridgeshire_casestudycambridgeshire_casestudy
cambridgeshire_casestudyGraham Baker
 
Presentasi Penyuluhan Arica Rovi Susanti 2014
Presentasi Penyuluhan Arica Rovi Susanti 2014Presentasi Penyuluhan Arica Rovi Susanti 2014
Presentasi Penyuluhan Arica Rovi Susanti 2014Arica Susanti
 
Want Easier Decision Making Just Listen to Your Users
Want Easier Decision Making Just Listen to Your Users Want Easier Decision Making Just Listen to Your Users
Want Easier Decision Making Just Listen to Your Users Mikan Associates
 
Context-aware systems and Linked Data
Context-aware systems and Linked DataContext-aware systems and Linked Data
Context-aware systems and Linked DataVille Seppänen
 
Bab 1 tempat umum
Bab 1 tempat umumBab 1 tempat umum
Bab 1 tempat umumFirda_123
 
Iffrig, Christian resume (August 2015)
Iffrig, Christian resume (August 2015)Iffrig, Christian resume (August 2015)
Iffrig, Christian resume (August 2015)Christian Iffrig
 
Top 8 product marketing specialist resume samples
Top 8 product marketing specialist resume samplesTop 8 product marketing specialist resume samples
Top 8 product marketing specialist resume sampleshallerharry710
 
ở đâu thiết kế clip quảng cáo chuyên nghiệp
ở đâu thiết kế clip quảng cáo chuyên nghiệpở đâu thiết kế clip quảng cáo chuyên nghiệp
ở đâu thiết kế clip quảng cáo chuyên nghiệpollie174
 
Top 8 administrative support specialist resume samples
Top 8 administrative support specialist resume samplesTop 8 administrative support specialist resume samples
Top 8 administrative support specialist resume sampleshallerharry710
 
Resume-Amar.compressed
Resume-Amar.compressedResume-Amar.compressed
Resume-Amar.compressedAmarjeet Kumar
 
Chief underwriting officer performance appraisal
Chief underwriting officer performance appraisalChief underwriting officer performance appraisal
Chief underwriting officer performance appraisalhernandezjoshua395
 
Click to see more www.loans-infor.com
Click to see more www.loans-infor.comClick to see more www.loans-infor.com
Click to see more www.loans-infor.commalika dy
 
SunPower Module 40 Year Useful Life
SunPower Module 40 Year Useful LifeSunPower Module 40 Year Useful Life
SunPower Module 40 Year Useful LifeYun Embly
 
KEPERCAYAAN GURU
KEPERCAYAAN GURUKEPERCAYAAN GURU
KEPERCAYAAN GURUNurAlias91
 

Destacado (19)

Get started with dropboxPCSK9
Get started with dropboxPCSK9Get started with dropboxPCSK9
Get started with dropboxPCSK9
 
cambridgeshire_casestudy
cambridgeshire_casestudycambridgeshire_casestudy
cambridgeshire_casestudy
 
Presentasi Penyuluhan Arica Rovi Susanti 2014
Presentasi Penyuluhan Arica Rovi Susanti 2014Presentasi Penyuluhan Arica Rovi Susanti 2014
Presentasi Penyuluhan Arica Rovi Susanti 2014
 
Want Easier Decision Making Just Listen to Your Users
Want Easier Decision Making Just Listen to Your Users Want Easier Decision Making Just Listen to Your Users
Want Easier Decision Making Just Listen to Your Users
 
Context-aware systems and Linked Data
Context-aware systems and Linked DataContext-aware systems and Linked Data
Context-aware systems and Linked Data
 
Bab 1 tempat umum
Bab 1 tempat umumBab 1 tempat umum
Bab 1 tempat umum
 
Iffrig, Christian resume (August 2015)
Iffrig, Christian resume (August 2015)Iffrig, Christian resume (August 2015)
Iffrig, Christian resume (August 2015)
 
Top 8 product marketing specialist resume samples
Top 8 product marketing specialist resume samplesTop 8 product marketing specialist resume samples
Top 8 product marketing specialist resume samples
 
ở đâu thiết kế clip quảng cáo chuyên nghiệp
ở đâu thiết kế clip quảng cáo chuyên nghiệpở đâu thiết kế clip quảng cáo chuyên nghiệp
ở đâu thiết kế clip quảng cáo chuyên nghiệp
 
Top 8 administrative support specialist resume samples
Top 8 administrative support specialist resume samplesTop 8 administrative support specialist resume samples
Top 8 administrative support specialist resume samples
 
Resume-Amar.compressed
Resume-Amar.compressedResume-Amar.compressed
Resume-Amar.compressed
 
Exm
ExmExm
Exm
 
Pelajaran 2
Pelajaran 2Pelajaran 2
Pelajaran 2
 
Chief underwriting officer performance appraisal
Chief underwriting officer performance appraisalChief underwriting officer performance appraisal
Chief underwriting officer performance appraisal
 
Click to see more www.loans-infor.com
Click to see more www.loans-infor.comClick to see more www.loans-infor.com
Click to see more www.loans-infor.com
 
SunPower Module 40 Year Useful Life
SunPower Module 40 Year Useful LifeSunPower Module 40 Year Useful Life
SunPower Module 40 Year Useful Life
 
Social Media for Municipalities
Social Media for MunicipalitiesSocial Media for Municipalities
Social Media for Municipalities
 
KEPERCAYAAN GURU
KEPERCAYAAN GURUKEPERCAYAAN GURU
KEPERCAYAAN GURU
 
Pelajaran3
Pelajaran3Pelajaran3
Pelajaran3
 

Similar a PyLecture3 -json-

Basics of Python programming (part 2)
Basics of Python programming (part 2)Basics of Python programming (part 2)
Basics of Python programming (part 2)Pedro Rodrigues
 
PyLecture4 -Python Basics2-
PyLecture4 -Python Basics2-PyLecture4 -Python Basics2-
PyLecture4 -Python Basics2-Yoshiki Satotani
 
JSON Data Parsing in Snowflake (By Faysal Shaarani)
JSON Data Parsing in Snowflake (By Faysal Shaarani)JSON Data Parsing in Snowflake (By Faysal Shaarani)
JSON Data Parsing in Snowflake (By Faysal Shaarani)Faysal Shaarani (MBA)
 
Python Data Types with realistical approach.pptx
Python Data Types with realistical approach.pptxPython Data Types with realistical approach.pptx
Python Data Types with realistical approach.pptxMuhammadUmar890FETBS
 
Scott Anderson [InfluxData] | New & Upcoming Flux Features | InfluxDays 2022
Scott Anderson [InfluxData] | New & Upcoming Flux Features | InfluxDays 2022Scott Anderson [InfluxData] | New & Upcoming Flux Features | InfluxDays 2022
Scott Anderson [InfluxData] | New & Upcoming Flux Features | InfluxDays 2022InfluxData
 
Declarative Thinking, Declarative Practice
Declarative Thinking, Declarative PracticeDeclarative Thinking, Declarative Practice
Declarative Thinking, Declarative PracticeKevlin Henney
 
GTR-Python-Using Web Services notesgtr.ppt
GTR-Python-Using Web Services notesgtr.pptGTR-Python-Using Web Services notesgtr.ppt
GTR-Python-Using Web Services notesgtr.pptrajugt3
 
Scala in a Java 8 World
Scala in a Java 8 WorldScala in a Java 8 World
Scala in a Java 8 WorldDaniel Blyth
 
JSON and MongoDB in R
JSON and MongoDB in RJSON and MongoDB in R
JSON and MongoDB in RLeon Kim
 
Avoiding Bad Database Surprises: Simulation and Scalability - Steven Lott
Avoiding Bad Database Surprises: Simulation and Scalability - Steven LottAvoiding Bad Database Surprises: Simulation and Scalability - Steven Lott
Avoiding Bad Database Surprises: Simulation and Scalability - Steven LottPyData
 
第二讲 Python基礎
第二讲 Python基礎第二讲 Python基礎
第二讲 Python基礎juzihua1102
 
第二讲 预备-Python基礎
第二讲 预备-Python基礎第二讲 预备-Python基礎
第二讲 预备-Python基礎anzhong70
 
Morel, a Functional Query Language
Morel, a Functional Query LanguageMorel, a Functional Query Language
Morel, a Functional Query LanguageJulian Hyde
 
Kotlin for Android Developers
Kotlin for Android DevelopersKotlin for Android Developers
Kotlin for Android DevelopersHassan Abid
 
Computational Social Science, Lecture 09: Data Wrangling
Computational Social Science, Lecture 09: Data WranglingComputational Social Science, Lecture 09: Data Wrangling
Computational Social Science, Lecture 09: Data Wranglingjakehofman
 

Similar a PyLecture3 -json- (20)

Basics of Python programming (part 2)
Basics of Python programming (part 2)Basics of Python programming (part 2)
Basics of Python programming (part 2)
 
PyLecture4 -Python Basics2-
PyLecture4 -Python Basics2-PyLecture4 -Python Basics2-
PyLecture4 -Python Basics2-
 
JSON Data Parsing in Snowflake (By Faysal Shaarani)
JSON Data Parsing in Snowflake (By Faysal Shaarani)JSON Data Parsing in Snowflake (By Faysal Shaarani)
JSON Data Parsing in Snowflake (By Faysal Shaarani)
 
Python Data Types with realistical approach.pptx
Python Data Types with realistical approach.pptxPython Data Types with realistical approach.pptx
Python Data Types with realistical approach.pptx
 
Scott Anderson [InfluxData] | New & Upcoming Flux Features | InfluxDays 2022
Scott Anderson [InfluxData] | New & Upcoming Flux Features | InfluxDays 2022Scott Anderson [InfluxData] | New & Upcoming Flux Features | InfluxDays 2022
Scott Anderson [InfluxData] | New & Upcoming Flux Features | InfluxDays 2022
 
Declarative Thinking, Declarative Practice
Declarative Thinking, Declarative PracticeDeclarative Thinking, Declarative Practice
Declarative Thinking, Declarative Practice
 
GTR-Python-Using Web Services notesgtr.ppt
GTR-Python-Using Web Services notesgtr.pptGTR-Python-Using Web Services notesgtr.ppt
GTR-Python-Using Web Services notesgtr.ppt
 
R learning by examples
R learning by examplesR learning by examples
R learning by examples
 
Scala in a Java 8 World
Scala in a Java 8 WorldScala in a Java 8 World
Scala in a Java 8 World
 
JSON and MongoDB in R
JSON and MongoDB in RJSON and MongoDB in R
JSON and MongoDB in R
 
Avoiding Bad Database Surprises: Simulation and Scalability - Steven Lott
Avoiding Bad Database Surprises: Simulation and Scalability - Steven LottAvoiding Bad Database Surprises: Simulation and Scalability - Steven Lott
Avoiding Bad Database Surprises: Simulation and Scalability - Steven Lott
 
Files,blocks and functions in R
Files,blocks and functions in RFiles,blocks and functions in R
Files,blocks and functions in R
 
第二讲 Python基礎
第二讲 Python基礎第二讲 Python基礎
第二讲 Python基礎
 
第二讲 预备-Python基礎
第二讲 预备-Python基礎第二讲 预备-Python基礎
第二讲 预备-Python基礎
 
Xml basics concepts
Xml basics conceptsXml basics concepts
Xml basics concepts
 
Morel, a Functional Query Language
Morel, a Functional Query LanguageMorel, a Functional Query Language
Morel, a Functional Query Language
 
Kotlin for Android Developers
Kotlin for Android DevelopersKotlin for Android Developers
Kotlin for Android Developers
 
Computational Social Science, Lecture 09: Data Wrangling
Computational Social Science, Lecture 09: Data WranglingComputational Social Science, Lecture 09: Data Wrangling
Computational Social Science, Lecture 09: Data Wrangling
 
JSON.pptx
JSON.pptxJSON.pptx
JSON.pptx
 
Swift & JSON
Swift & JSONSwift & JSON
Swift & JSON
 

Más de Yoshiki Satotani

Más de Yoshiki Satotani (6)

Basic practice of R
Basic practice of RBasic practice of R
Basic practice of R
 
Basic use of Python (Practice)
Basic use of Python (Practice)Basic use of Python (Practice)
Basic use of Python (Practice)
 
Basic use of Python
Basic use of PythonBasic use of Python
Basic use of Python
 
Py lecture5 python plots
Py lecture5 python plotsPy lecture5 python plots
Py lecture5 python plots
 
PyLecture2 -NetworkX-
PyLecture2 -NetworkX-PyLecture2 -NetworkX-
PyLecture2 -NetworkX-
 
PyLecture1 -Python Basics-
PyLecture1 -Python Basics-PyLecture1 -Python Basics-
PyLecture1 -Python Basics-
 

Último

Understanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM ArchitectureUnderstanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM Architecturerahul_net
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Velvetech LLC
 
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxReal-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxRTS corp
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfMarharyta Nedzelska
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxAndreas Kunz
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Rob Geurden
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...Technogeeks
 
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...Akihiro Suda
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfFerryKemperman
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalLionel Briand
 

Último (20)

Understanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM ArchitectureUnderstanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM Architecture
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...
 
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxReal-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...
 
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdf
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive Goal
 
Advantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your BusinessAdvantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your Business
 

PyLecture3 -json-

  • 1.
  • 2.  Basic NetworkX › Adding node(s), edges(s) to a graph › Drawing graphs › Networks characteristics  Degree distribution › Creating network of Twitter
  • 3.  Dictionaries – compound data type  Found in other languages as “map”, “associative memories”, or “associative arrays”  Lists vs Dictionaries › You can use only integer number as index on lists Like a[0], a[-1] › You can use integer numbers and strings as key on dictionaries(if its value exists) Like d[0], d[‘foo’], d[‘bar’]
  • 4.  Creating a dictionary tel = {‘John’:0000, ‘Jane’:0001, ‘Joe’:0002}  Adding key and value tel[‘Joan’] = 0003  Getting value from key tel[‘Jane’]  Setting value from key tel[‘Joe’] = 0004  Removing value from key del tel[‘John’]  Getting key list of a dictionary tel.keys()
  • 5.  you can nest dictionaries, like data = {‘one’: {‘one’: 11, ‘two’: 12}, ‘two’: {‘one’: 21, ‘two’: 22}} print data[‘one’][‘two’]  Also, you can combine lists and dictionaries, like data = {‘employees’:[ {‘firstName’: ‘John’, ‘lastName’: ‘Doe’}, {‘firstName’: ‘Anna’, ‘lastName’: ‘Smith’}, {‘firstName’: ‘Peter’, ‘lastName’: ‘Jones’} ] print data[‘employees’][2][‘firstName’]
  • 6.  JSON (JavaScript Object Notation) is a lightweight data-interchange format.  It is easy for humans to read and write.  It is easy for machines to parse and generate. From http://json.org/
  • 7.  A collection of name/value pairs. In various languages, this is realized as an object, record, struct, dictionary, hash table, keyed list, or associative array.  An ordered list of values. In most languages, this is realized as an array, vector, list, or sequence.  From http://json.org/
  • 9. import json  Load json from raw string data = json.loads(‘{"employees":[ {"firstName":"John", "lastName":"Doe"}, {"firstName":"Anna", "lastName":"Smith"}, {"firstName":"Peter", "lastName":"Jones"} ]}’ print data[‘employees’][2][‘firstName’]  From json file(save previous json as sample.json) with open(‘sample.json’, ‘r’) as f: data = json.load(f) print data[‘employees’][2][‘firstName’]  From url Import urllib2 data = json.load(urllib2.urlopen(‘http://time.jsontest.com’)) print ‘Today is’, data[‘date’]
  • 10.  http://www.ebay.com/  An online auction and shopping site
  • 11.  HTTP GET URL(search items that its keyword is “harry potter phoenix” http://svcs.ebay.com/services/search/FindingService/v1? OPERATION-NAME=findItemsByKeywords &SERVICE-VERSION=1.0.0 &SECURITY-APPNAME=YourAppID &RESPONSE-DATA-FORMAT=json &REST-PAYLOAD &keywords=harry%20potter%20phoenix  YourAppID have to be replaced  More Information: › http://developer.ebay.com/Devzone/finding/Concepts/MakingACall.html › http://developer.ebay.com/Devzone/finding/CallRef/index.html
  • 12.  https://github.com/  An online software development environment
  • 13.  HTTP GET URL(searches repositories(projects) that its keyword is “tetris” and written in assembly language) https://api.github.com/search/repositories? q=tetris+language:assembly &sort=stars &order=desc  More information: › https://developer.github.com/v3/ › https://developer.github.com/v3/search/
  • 14.  Saving import networkx as nx import pickle G = Graph() # some works here pickle.dump(G, open(‘your_graph.txt’, ‘w’))  Loading G = pickle.load(open(‘your_graph.txt’, ‘r’))
  • 15.  Dictionaries(Python data structure)  Brief explanation of JSON  Getting JSON Data › From raw string › From JSON file › From URL  Example: eBay and GitHub  Saving/loading networks