The telecommunication sector is made up of companies that make communication possible on a global scale, whether it is through the phone or the Internet, through airwaves or cables, through wires or wirelessly. These companies created the infrastructure that allows data in words, voice, audio or video to be sent anywhere in the world. The largest companies in the sector are telephone (both wired and wireless) operators, satellite companies, cable companies, and internet service providers.
These software components cover functions across Conferencing, Email, Internet, Network, Telephony, Wireless areas.
Popular New Releases in Telecom
fastlane
2.205.2 Improvements
lottie-android
5.0.3
Rocket.Chat
4.7.0-rc.0
joplin
v2.8.2
react-native-elements
4.0.0-beta.0
Popular Libraries in Telecom
by fastlane ruby
34761 MIT
🚀 The easiest way to automate building and releasing your iOS and Android apps
by airbnb java
32616 Apache-2.0
Render After Effects animations natively on Android and iOS, Web, and React Native
by RocketChat javascript
32191 NOASSERTION
The communications platform that puts data protection first.
by laurent22 typescript
29233 NOASSERTION
Joplin - an open source note taking and to-do application with synchronization capabilities for Windows, macOS, Linux, Android and iOS.
by trailofbits python
24206 AGPL-3.0
Set up a personal VPN in the cloud
by signalapp java
22277 GPL-3.0
A private messenger for Android.
by react-native-elements typescript
22069 MIT
Cross-Platform React Native UI Toolkit
by dotnet-architecture csharp
19919 MIT
Cross-platform .NET sample microservices and container based application that runs on Linux Windows and macOS. Powered by .NET 6, Docker Containers and Azure Kubernetes Services. Supports Visual Studio, VS for Mac and CLI based environments with Docker CLI, dotnet CLI, VS Code or any other code editor.
by TeamNewPipe java
18715 GPL-3.0
A libre lightweight streaming front-end for Android.
Trending New libraries in Telecom
by nic-delhi java
2830 NOASSERTION
Aarogya Setu Android app native code
by KwaiAppTeam c++
2354 NOASSERTION
KOOM is an OOM killer on mobile platform by Kwai.
by intel-isl java
1827 MIT
OpenBot leverages smartphones as brains for low-cost robots. We have designed a small electric vehicle that costs about $50 and serves as a robot body. Our software stack for Android smartphones supports advanced robotics workloads such as person following and real-time autonomous navigation.
by adw0rd python
782 MIT
🔥 The fastest and powerful Python library for Instagram Private API 2022
by emanuele-f c
484 GPL-3.0
No-root network monitor and traffic dump tool for Android devices
by GramAddict python
300 MIT
Completely free and open-source human-like Instagram bot. Powered by UIAutomator2 and compatible with basically any Android device 5.0+ that can run Instagram - real or emulated.
by yuvraj24 javascript
232 MIT
WhatsApp Clone provides an in-depth view of implementation on how to create a full-stack, mobile, hybrid web application from scratch using React Native, ReactJs, Typescript, NodeJs, ExpressJs, MongoDB, Socket.io, Heroku & Firebase Deployment. 🔥🔥
by garganurag893 javascript
208 MIT
React Native component for phone number.
by ROS-Mobile java
152
Visualization and controlling application for Android
Top Authors in Telecom
1
24 Libraries
210
2
10 Libraries
146
3
8 Libraries
1708
4
6 Libraries
110
5
6 Libraries
47
6
4 Libraries
33
7
4 Libraries
23
8
4 Libraries
84
9
4 Libraries
67
10
4 Libraries
47
1
24 Libraries
210
2
10 Libraries
146
3
8 Libraries
1708
4
6 Libraries
110
5
6 Libraries
47
6
4 Libraries
33
7
4 Libraries
23
8
4 Libraries
84
9
4 Libraries
67
10
4 Libraries
47
Trending Kits in Telecom
No Trending Kits are available at this moment for Telecom
Trending Discussions on Telecom
Find a value in column in hive
Python loop through ndjson file data
Incoming call notification - Android/iOS
How to get the phone number and SIM card slot for the current device, on the callback of onCallAdded?
How do I convert an HTML table into JSON in Logic Apps
A more complex Island & Gaps problem in SQL
react native onPress not working in library in android
Read a section in FHIR Document Reference Data
How can I reorder an ELEMENT inside of an OBJECT of an array of OBJECTS NOT sort?
how to normalize nested json in python
QUESTION
Find a value in column in hive
Asked 2022-Mar-18 at 15:09I have a requirement in hive to find a value in a column, data is ";" separated values in single column. if my required value present it should result TRUE else FALSE.
Ex: data in a single column is
Row1: insurance;finance;telecom
Row2: insurance, retail
Row3: finance, telecom, internal
Like this I have different values in a column. I wanted to find if the column contains "finance" or not. If present it should result TRUE else FALSE
output: Row1: TRUE
Row2: FALSE
Row3: TRUE
Please help. Thanks in advance.
ANSWER
Answered 2022-Mar-18 at 15:09If you are looking for single hardcode value, you can use like operator.
where col like '%finance%'.
But if you want it to be a variable qnd coming from another table you can use it like this
1Select...
2From table1 t1,
3join table2 t2 on t1.col like concat('%', t2.colpattern, '%')
4
QUESTION
Python loop through ndjson file data
Asked 2022-Feb-22 at 12:04I have ndjson
file Patients.ndjson
1{"resourceType":"Patient","id":"ewnMwMK-UNvVvM.bakFSlkw3","extension":[{"extension":[{"valueCoding":{"system":"http://terminology.hl7.org/CodeSystem/v3-NullFlavor","code":"UNK","display":"Unknown"},"url":"ombCategory"},{"valueString":"Unknown","url":"text"}],"url":"http://hl7.org/fhir/us/core/StructureDefinition/us-core-race"},{"extension":[{"valueString":"Unknown","url":"text"}],"url":"http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity"},{"valueCodeableConcept":{"coding":[{"system":"urn:oid:1.2.840.114350.1.13.520.3.7.10.698084.130.657370.334258","code":"female"}]},"url":"http://open.epic.com/FHIR/StructureDefinition/extension/legal-sex"},{"valueCodeableConcept":{"coding":[{"system":"urn:oid:1.2.840.114350.1.13.520.3.7.10.698084.130.657370.334258","code":"female"}]},"url":"http://open.epic.com/FHIR/StructureDefinition/extension/sex-for-clinical-use"},{"valueCode":"F","url":"http://hl7.org/fhir/us/core/StructureDefinition/us-core-birthsex"}],"identifier":[{"use":"usual","type":{"text":"EPIC"},"system":"urn:oid:1.2.840.114350.1.13.520.3.7.5.737384.0","value":"E9254"},{"use":"usual","type":{"text":"EXTERNAL"},"system":"urn:oid:1.2.840.114350.1.13.520.3.7.2.698084","value":"Z11363"},{"use":"usual","type":{"text":"FHIR"},"system":"http://open.epic.com/FHIR/StructureDefinition/patient-dstu2-fhir-id","value":"TYO3ktvhYAUhbae7JuBwDdpyIbUZc8kZG.bMW2ZwVnwgB"},{"use":"usual","type":{"text":"FHIR STU3"},"system":"http://open.epic.com/FHIR/StructureDefinition/patient-fhir-id","value":"ewnMwMK-UNvVvM.bakFSlkw3"},{"use":"usual","type":{"text":"PAS"},"system":"urn:oid:2.16.840.1.113883.2.1.3.12.1.1","value":"2005294"},{"use":"usual","type":{"text":"INTERNAL"},"system":"urn:oid:1.2.840.114350.1.13.520.3.7.2.698084","value":" Z11363"}],"active":true,"name":[{"extension":[{"valueCode":"NL4","url":"http://hl7.org/fhir/StructureDefinition/humanname-assembly-order"}],"use":"official","text":"Test ADVANCEPREPTWO","family":"ADVANCEPREPTWO","given":["Test"],"_family":{"extension":[{"valueString":"Advancepreptwo","url":"http://hl7.org/fhir/StructureDefinition/humanname-own-name"}]}},{"extension":[{"valueCode":"NL4","url":"http://hl7.org/fhir/StructureDefinition/humanname-assembly-order"}],"use":"usual","text":"Test ADVANCEPREPTWO","family":"ADVANCEPREPTWO","given":["Test"],"_family":{"extension":[{"valueString":"Advancepreptwo","url":"http://hl7.org/fhir/StructureDefinition/humanname-own-name"}]}}],"gender":"female","birthDate":"2006-10-07","deceasedBoolean":false,"maritalStatus":{"text":"Single"}}
2{"resourceType":"Patient","id":"exU8JSL0p8npSw5g1QYAyOw3","extension":[{"extension":[{"valueCoding":{"system":"http://terminology.hl7.org/CodeSystem/v3-NullFlavor","code":"UNK","display":"Unknown"},"url":"ombCategory"},{"valueString":"Unknown","url":"text"}],"url":"http://hl7.org/fhir/us/core/StructureDefinition/us-core-race"},{"extension":[{"valueString":"Unknown","url":"text"}],"url":"http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity"},{"valueCodeableConcept":{"coding":[{"system":"urn:oid:1.2.840.114350.1.13.520.3.7.10.698084.130.657370.334258","code":"female"}]},"url":"http://open.epic.com/FHIR/StructureDefinition/extension/legal-sex"},{"valueCodeableConcept":{"coding":[{"system":"urn:oid:1.2.840.114350.1.13.520.3.7.10.698084.130.657370.334258","code":"female"}]},"url":"http://open.epic.com/FHIR/StructureDefinition/extension/sex-for-clinical-use"},{"valueCode":"F","url":"http://hl7.org/fhir/us/core/StructureDefinition/us-core-birthsex"}],"identifier":[{"use":"usual","type":{"text":"EPIC"},"system":"urn:oid:1.2.840.114350.1.13.520.3.7.5.737384.0","value":"E9340"},{"use":"usual","type":{"text":"EXTERNAL"},"system":"urn:oid:1.2.840.114350.1.13.520.3.7.2.698084","value":"Z11449"},{"use":"usual","type":{"text":"FHIR"},"system":"http://open.epic.com/FHIR/StructureDefinition/patient-dstu2-fhir-id","value":"TwzgMHMPt5OhnHkFA2H2DudL3FU8qcRZkZyn0F3extkAB"},{"use":"usual","type":{"text":"FHIR STU3"},"system":"http://open.epic.com/FHIR/StructureDefinition/patient-fhir-id","value":"exU8JSL0p8npSw5g1QYAyOw3"},{"use":"usual","type":{"text":"PAS"},"system":"urn:oid:2.16.840.1.113883.2.1.3.12.1.1","value":"2005380"},{"use":"usual","type":{"text":"INTERNAL"},"system":"urn:oid:1.2.840.114350.1.13.520.3.7.2.698084","value":" Z11449"}],"active":true,"name":[{"extension":[{"valueCode":"NL4","url":"http://hl7.org/fhir/StructureDefinition/humanname-assembly-order"}],"use":"official","text":"BcnScTenAugTwentyOne UPGRADETEST","family":"UPGRADETEST","given":["BcnScTenAugTwentyOne"],"_family":{"extension":[{"valueString":"UpgradeTest","url":"http://hl7.org/fhir/StructureDefinition/humanname-own-name"}]}},{"extension":[{"valueCode":"NL4","url":"http://hl7.org/fhir/StructureDefinition/humanname-assembly-order"}],"use":"usual","text":"BcnScTenAugTwentyOne UPGRADETEST","family":"UPGRADETEST","given":["BcnScTenAugTwentyOne"],"_family":{"extension":[{"valueString":"UpgradeTest","url":"http://hl7.org/fhir/StructureDefinition/humanname-own-name"}]}}],"gender":"female","birthDate":"2019-09-21","deceasedBoolean":false,"maritalStatus":{"text":"Single"}}
3{"resourceType":"Patient","id":"ezER-U3fAMP-WvI-Fc8V9wQ3","extension":[{"extension":[{"valueCoding":{"system":"http://terminology.hl7.org/CodeSystem/v3-NullFlavor","code":"UNK","display":"Unknown"},"url":"ombCategory"},{"valueString":"Unknown","url":"text"}],"url":"http://hl7.org/fhir/us/core/StructureDefinition/us-core-race"},{"extension":[{"valueString":"Unknown","url":"text"}],"url":"http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity"},{"valueCodeableConcept":{"coding":[{"system":"urn:oid:1.2.840.114350.1.13.520.3.7.10.698084.130.657370.334258","code":"male"}]},"url":"http://open.epic.com/FHIR/StructureDefinition/extension/legal-sex"},{"valueCodeableConcept":{"coding":[{"system":"urn:oid:1.2.840.114350.1.13.520.3.7.10.698084.130.657370.334258","code":"male"}]},"url":"http://open.epic.com/FHIR/StructureDefinition/extension/sex-for-clinical-use"},{"valueCode":"M","url":"http://hl7.org/fhir/us/core/StructureDefinition/us-core-birthsex"}],"identifier":[{"use":"usual","type":{"text":"EPIC"},"system":"urn:oid:1.2.840.114350.1.13.520.3.7.5.737384.0","value":"E9411"},{"use":"usual","type":{"text":"EXTERNAL"},"system":"urn:oid:1.2.840.114350.1.13.520.3.7.2.698084","value":"Z11522"},{"use":"usual","type":{"text":"FHIR"},"system":"http://open.epic.com/FHIR/StructureDefinition/patient-dstu2-fhir-id","value":"T2oDrcOUw0w.1ZUdthu24c7V95lTOTEOUPRqBqGn99KEB"},{"use":"usual","type":{"text":"FHIR STU3"},"system":"http://open.epic.com/FHIR/StructureDefinition/patient-fhir-id","value":"ezER-U3fAMP-WvI-Fc8V9wQ3"},{"use":"usual","type":{"text":"PAS"},"system":"urn:oid:2.16.840.1.113883.2.1.3.12.1.1","value":"2005452"},{"use":"usual","type":{"text":"INTERNAL"},"system":"urn:oid:1.2.840.114350.1.13.520.3.7.2.698084","value":" Z11522"}],"active":true,"name":[{"extension":[{"valueCode":"NL4","url":"http://hl7.org/fhir/StructureDefinition/humanname-assembly-order"}],"use":"official","text":"Fred TEST","family":"TEST","given":["Fred"],"_family":{"extension":[{"valueString":"Test","url":"http://hl7.org/fhir/StructureDefinition/humanname-own-name"}]}},{"extension":[{"valueCode":"NL4","url":"http://hl7.org/fhir/StructureDefinition/humanname-assembly-order"}],"use":"usual","text":"Fred TEST","family":"TEST","given":["Fred"],"_family":{"extension":[{"valueString":"Test","url":"http://hl7.org/fhir/StructureDefinition/humanname-own-name"}]}}],"telecom":[{"system":"phone","value":"07594 832748","use":"mobile"},{"system":"email","value":"fred@email.com"}],"gender":"male","birthDate":"1967-01-19","deceasedBoolean":false,"address":[{"use":"old","line":["123 Anywhere"],"city":"Bristol","postalCode":"BS1 6JY","country":"ENG"},{"use":"home","line":["123 Anywhere"],"city":"Bristol","postalCode":"BS1 6JY","country":"ENG","period":{"start":"2022-01-19"}}],"maritalStatus":{"text":"Single"},"communication":[{"language":{"coding":[{"system":"urn:ietf:bcp:47","code":"en","display":"English"}],"text":"English"},"preferred":true}]}
4
I am opening ndjson file and trying to loop through the dictionaries to pick all the patient's id
, birthDate
and deceasedDateTime
Python Code to read ndjson file
1{"resourceType":"Patient","id":"ewnMwMK-UNvVvM.bakFSlkw3","extension":[{"extension":[{"valueCoding":{"system":"http://terminology.hl7.org/CodeSystem/v3-NullFlavor","code":"UNK","display":"Unknown"},"url":"ombCategory"},{"valueString":"Unknown","url":"text"}],"url":"http://hl7.org/fhir/us/core/StructureDefinition/us-core-race"},{"extension":[{"valueString":"Unknown","url":"text"}],"url":"http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity"},{"valueCodeableConcept":{"coding":[{"system":"urn:oid:1.2.840.114350.1.13.520.3.7.10.698084.130.657370.334258","code":"female"}]},"url":"http://open.epic.com/FHIR/StructureDefinition/extension/legal-sex"},{"valueCodeableConcept":{"coding":[{"system":"urn:oid:1.2.840.114350.1.13.520.3.7.10.698084.130.657370.334258","code":"female"}]},"url":"http://open.epic.com/FHIR/StructureDefinition/extension/sex-for-clinical-use"},{"valueCode":"F","url":"http://hl7.org/fhir/us/core/StructureDefinition/us-core-birthsex"}],"identifier":[{"use":"usual","type":{"text":"EPIC"},"system":"urn:oid:1.2.840.114350.1.13.520.3.7.5.737384.0","value":"E9254"},{"use":"usual","type":{"text":"EXTERNAL"},"system":"urn:oid:1.2.840.114350.1.13.520.3.7.2.698084","value":"Z11363"},{"use":"usual","type":{"text":"FHIR"},"system":"http://open.epic.com/FHIR/StructureDefinition/patient-dstu2-fhir-id","value":"TYO3ktvhYAUhbae7JuBwDdpyIbUZc8kZG.bMW2ZwVnwgB"},{"use":"usual","type":{"text":"FHIR STU3"},"system":"http://open.epic.com/FHIR/StructureDefinition/patient-fhir-id","value":"ewnMwMK-UNvVvM.bakFSlkw3"},{"use":"usual","type":{"text":"PAS"},"system":"urn:oid:2.16.840.1.113883.2.1.3.12.1.1","value":"2005294"},{"use":"usual","type":{"text":"INTERNAL"},"system":"urn:oid:1.2.840.114350.1.13.520.3.7.2.698084","value":" Z11363"}],"active":true,"name":[{"extension":[{"valueCode":"NL4","url":"http://hl7.org/fhir/StructureDefinition/humanname-assembly-order"}],"use":"official","text":"Test ADVANCEPREPTWO","family":"ADVANCEPREPTWO","given":["Test"],"_family":{"extension":[{"valueString":"Advancepreptwo","url":"http://hl7.org/fhir/StructureDefinition/humanname-own-name"}]}},{"extension":[{"valueCode":"NL4","url":"http://hl7.org/fhir/StructureDefinition/humanname-assembly-order"}],"use":"usual","text":"Test ADVANCEPREPTWO","family":"ADVANCEPREPTWO","given":["Test"],"_family":{"extension":[{"valueString":"Advancepreptwo","url":"http://hl7.org/fhir/StructureDefinition/humanname-own-name"}]}}],"gender":"female","birthDate":"2006-10-07","deceasedBoolean":false,"maritalStatus":{"text":"Single"}}
2{"resourceType":"Patient","id":"exU8JSL0p8npSw5g1QYAyOw3","extension":[{"extension":[{"valueCoding":{"system":"http://terminology.hl7.org/CodeSystem/v3-NullFlavor","code":"UNK","display":"Unknown"},"url":"ombCategory"},{"valueString":"Unknown","url":"text"}],"url":"http://hl7.org/fhir/us/core/StructureDefinition/us-core-race"},{"extension":[{"valueString":"Unknown","url":"text"}],"url":"http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity"},{"valueCodeableConcept":{"coding":[{"system":"urn:oid:1.2.840.114350.1.13.520.3.7.10.698084.130.657370.334258","code":"female"}]},"url":"http://open.epic.com/FHIR/StructureDefinition/extension/legal-sex"},{"valueCodeableConcept":{"coding":[{"system":"urn:oid:1.2.840.114350.1.13.520.3.7.10.698084.130.657370.334258","code":"female"}]},"url":"http://open.epic.com/FHIR/StructureDefinition/extension/sex-for-clinical-use"},{"valueCode":"F","url":"http://hl7.org/fhir/us/core/StructureDefinition/us-core-birthsex"}],"identifier":[{"use":"usual","type":{"text":"EPIC"},"system":"urn:oid:1.2.840.114350.1.13.520.3.7.5.737384.0","value":"E9340"},{"use":"usual","type":{"text":"EXTERNAL"},"system":"urn:oid:1.2.840.114350.1.13.520.3.7.2.698084","value":"Z11449"},{"use":"usual","type":{"text":"FHIR"},"system":"http://open.epic.com/FHIR/StructureDefinition/patient-dstu2-fhir-id","value":"TwzgMHMPt5OhnHkFA2H2DudL3FU8qcRZkZyn0F3extkAB"},{"use":"usual","type":{"text":"FHIR STU3"},"system":"http://open.epic.com/FHIR/StructureDefinition/patient-fhir-id","value":"exU8JSL0p8npSw5g1QYAyOw3"},{"use":"usual","type":{"text":"PAS"},"system":"urn:oid:2.16.840.1.113883.2.1.3.12.1.1","value":"2005380"},{"use":"usual","type":{"text":"INTERNAL"},"system":"urn:oid:1.2.840.114350.1.13.520.3.7.2.698084","value":" Z11449"}],"active":true,"name":[{"extension":[{"valueCode":"NL4","url":"http://hl7.org/fhir/StructureDefinition/humanname-assembly-order"}],"use":"official","text":"BcnScTenAugTwentyOne UPGRADETEST","family":"UPGRADETEST","given":["BcnScTenAugTwentyOne"],"_family":{"extension":[{"valueString":"UpgradeTest","url":"http://hl7.org/fhir/StructureDefinition/humanname-own-name"}]}},{"extension":[{"valueCode":"NL4","url":"http://hl7.org/fhir/StructureDefinition/humanname-assembly-order"}],"use":"usual","text":"BcnScTenAugTwentyOne UPGRADETEST","family":"UPGRADETEST","given":["BcnScTenAugTwentyOne"],"_family":{"extension":[{"valueString":"UpgradeTest","url":"http://hl7.org/fhir/StructureDefinition/humanname-own-name"}]}}],"gender":"female","birthDate":"2019-09-21","deceasedBoolean":false,"maritalStatus":{"text":"Single"}}
3{"resourceType":"Patient","id":"ezER-U3fAMP-WvI-Fc8V9wQ3","extension":[{"extension":[{"valueCoding":{"system":"http://terminology.hl7.org/CodeSystem/v3-NullFlavor","code":"UNK","display":"Unknown"},"url":"ombCategory"},{"valueString":"Unknown","url":"text"}],"url":"http://hl7.org/fhir/us/core/StructureDefinition/us-core-race"},{"extension":[{"valueString":"Unknown","url":"text"}],"url":"http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity"},{"valueCodeableConcept":{"coding":[{"system":"urn:oid:1.2.840.114350.1.13.520.3.7.10.698084.130.657370.334258","code":"male"}]},"url":"http://open.epic.com/FHIR/StructureDefinition/extension/legal-sex"},{"valueCodeableConcept":{"coding":[{"system":"urn:oid:1.2.840.114350.1.13.520.3.7.10.698084.130.657370.334258","code":"male"}]},"url":"http://open.epic.com/FHIR/StructureDefinition/extension/sex-for-clinical-use"},{"valueCode":"M","url":"http://hl7.org/fhir/us/core/StructureDefinition/us-core-birthsex"}],"identifier":[{"use":"usual","type":{"text":"EPIC"},"system":"urn:oid:1.2.840.114350.1.13.520.3.7.5.737384.0","value":"E9411"},{"use":"usual","type":{"text":"EXTERNAL"},"system":"urn:oid:1.2.840.114350.1.13.520.3.7.2.698084","value":"Z11522"},{"use":"usual","type":{"text":"FHIR"},"system":"http://open.epic.com/FHIR/StructureDefinition/patient-dstu2-fhir-id","value":"T2oDrcOUw0w.1ZUdthu24c7V95lTOTEOUPRqBqGn99KEB"},{"use":"usual","type":{"text":"FHIR STU3"},"system":"http://open.epic.com/FHIR/StructureDefinition/patient-fhir-id","value":"ezER-U3fAMP-WvI-Fc8V9wQ3"},{"use":"usual","type":{"text":"PAS"},"system":"urn:oid:2.16.840.1.113883.2.1.3.12.1.1","value":"2005452"},{"use":"usual","type":{"text":"INTERNAL"},"system":"urn:oid:1.2.840.114350.1.13.520.3.7.2.698084","value":" Z11522"}],"active":true,"name":[{"extension":[{"valueCode":"NL4","url":"http://hl7.org/fhir/StructureDefinition/humanname-assembly-order"}],"use":"official","text":"Fred TEST","family":"TEST","given":["Fred"],"_family":{"extension":[{"valueString":"Test","url":"http://hl7.org/fhir/StructureDefinition/humanname-own-name"}]}},{"extension":[{"valueCode":"NL4","url":"http://hl7.org/fhir/StructureDefinition/humanname-assembly-order"}],"use":"usual","text":"Fred TEST","family":"TEST","given":["Fred"],"_family":{"extension":[{"valueString":"Test","url":"http://hl7.org/fhir/StructureDefinition/humanname-own-name"}]}}],"telecom":[{"system":"phone","value":"07594 832748","use":"mobile"},{"system":"email","value":"fred@email.com"}],"gender":"male","birthDate":"1967-01-19","deceasedBoolean":false,"address":[{"use":"old","line":["123 Anywhere"],"city":"Bristol","postalCode":"BS1 6JY","country":"ENG"},{"use":"home","line":["123 Anywhere"],"city":"Bristol","postalCode":"BS1 6JY","country":"ENG","period":{"start":"2022-01-19"}}],"maritalStatus":{"text":"Single"},"communication":[{"language":{"coding":[{"system":"urn:ietf:bcp:47","code":"en","display":"English"}],"text":"English"},"preferred":true}]}
4import ndjson
5
6 with open('Patients.ndjson') as f:
7 data = ndjson.load(f)
8 return render_template('home.html', patient = data)
9
Html Template This for loop displays all the items and values in html page.
How do i only pick specific values id
, birthDate
and deceasedDateTime
from the given dictionaries?
1{"resourceType":"Patient","id":"ewnMwMK-UNvVvM.bakFSlkw3","extension":[{"extension":[{"valueCoding":{"system":"http://terminology.hl7.org/CodeSystem/v3-NullFlavor","code":"UNK","display":"Unknown"},"url":"ombCategory"},{"valueString":"Unknown","url":"text"}],"url":"http://hl7.org/fhir/us/core/StructureDefinition/us-core-race"},{"extension":[{"valueString":"Unknown","url":"text"}],"url":"http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity"},{"valueCodeableConcept":{"coding":[{"system":"urn:oid:1.2.840.114350.1.13.520.3.7.10.698084.130.657370.334258","code":"female"}]},"url":"http://open.epic.com/FHIR/StructureDefinition/extension/legal-sex"},{"valueCodeableConcept":{"coding":[{"system":"urn:oid:1.2.840.114350.1.13.520.3.7.10.698084.130.657370.334258","code":"female"}]},"url":"http://open.epic.com/FHIR/StructureDefinition/extension/sex-for-clinical-use"},{"valueCode":"F","url":"http://hl7.org/fhir/us/core/StructureDefinition/us-core-birthsex"}],"identifier":[{"use":"usual","type":{"text":"EPIC"},"system":"urn:oid:1.2.840.114350.1.13.520.3.7.5.737384.0","value":"E9254"},{"use":"usual","type":{"text":"EXTERNAL"},"system":"urn:oid:1.2.840.114350.1.13.520.3.7.2.698084","value":"Z11363"},{"use":"usual","type":{"text":"FHIR"},"system":"http://open.epic.com/FHIR/StructureDefinition/patient-dstu2-fhir-id","value":"TYO3ktvhYAUhbae7JuBwDdpyIbUZc8kZG.bMW2ZwVnwgB"},{"use":"usual","type":{"text":"FHIR STU3"},"system":"http://open.epic.com/FHIR/StructureDefinition/patient-fhir-id","value":"ewnMwMK-UNvVvM.bakFSlkw3"},{"use":"usual","type":{"text":"PAS"},"system":"urn:oid:2.16.840.1.113883.2.1.3.12.1.1","value":"2005294"},{"use":"usual","type":{"text":"INTERNAL"},"system":"urn:oid:1.2.840.114350.1.13.520.3.7.2.698084","value":" Z11363"}],"active":true,"name":[{"extension":[{"valueCode":"NL4","url":"http://hl7.org/fhir/StructureDefinition/humanname-assembly-order"}],"use":"official","text":"Test ADVANCEPREPTWO","family":"ADVANCEPREPTWO","given":["Test"],"_family":{"extension":[{"valueString":"Advancepreptwo","url":"http://hl7.org/fhir/StructureDefinition/humanname-own-name"}]}},{"extension":[{"valueCode":"NL4","url":"http://hl7.org/fhir/StructureDefinition/humanname-assembly-order"}],"use":"usual","text":"Test ADVANCEPREPTWO","family":"ADVANCEPREPTWO","given":["Test"],"_family":{"extension":[{"valueString":"Advancepreptwo","url":"http://hl7.org/fhir/StructureDefinition/humanname-own-name"}]}}],"gender":"female","birthDate":"2006-10-07","deceasedBoolean":false,"maritalStatus":{"text":"Single"}}
2{"resourceType":"Patient","id":"exU8JSL0p8npSw5g1QYAyOw3","extension":[{"extension":[{"valueCoding":{"system":"http://terminology.hl7.org/CodeSystem/v3-NullFlavor","code":"UNK","display":"Unknown"},"url":"ombCategory"},{"valueString":"Unknown","url":"text"}],"url":"http://hl7.org/fhir/us/core/StructureDefinition/us-core-race"},{"extension":[{"valueString":"Unknown","url":"text"}],"url":"http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity"},{"valueCodeableConcept":{"coding":[{"system":"urn:oid:1.2.840.114350.1.13.520.3.7.10.698084.130.657370.334258","code":"female"}]},"url":"http://open.epic.com/FHIR/StructureDefinition/extension/legal-sex"},{"valueCodeableConcept":{"coding":[{"system":"urn:oid:1.2.840.114350.1.13.520.3.7.10.698084.130.657370.334258","code":"female"}]},"url":"http://open.epic.com/FHIR/StructureDefinition/extension/sex-for-clinical-use"},{"valueCode":"F","url":"http://hl7.org/fhir/us/core/StructureDefinition/us-core-birthsex"}],"identifier":[{"use":"usual","type":{"text":"EPIC"},"system":"urn:oid:1.2.840.114350.1.13.520.3.7.5.737384.0","value":"E9340"},{"use":"usual","type":{"text":"EXTERNAL"},"system":"urn:oid:1.2.840.114350.1.13.520.3.7.2.698084","value":"Z11449"},{"use":"usual","type":{"text":"FHIR"},"system":"http://open.epic.com/FHIR/StructureDefinition/patient-dstu2-fhir-id","value":"TwzgMHMPt5OhnHkFA2H2DudL3FU8qcRZkZyn0F3extkAB"},{"use":"usual","type":{"text":"FHIR STU3"},"system":"http://open.epic.com/FHIR/StructureDefinition/patient-fhir-id","value":"exU8JSL0p8npSw5g1QYAyOw3"},{"use":"usual","type":{"text":"PAS"},"system":"urn:oid:2.16.840.1.113883.2.1.3.12.1.1","value":"2005380"},{"use":"usual","type":{"text":"INTERNAL"},"system":"urn:oid:1.2.840.114350.1.13.520.3.7.2.698084","value":" Z11449"}],"active":true,"name":[{"extension":[{"valueCode":"NL4","url":"http://hl7.org/fhir/StructureDefinition/humanname-assembly-order"}],"use":"official","text":"BcnScTenAugTwentyOne UPGRADETEST","family":"UPGRADETEST","given":["BcnScTenAugTwentyOne"],"_family":{"extension":[{"valueString":"UpgradeTest","url":"http://hl7.org/fhir/StructureDefinition/humanname-own-name"}]}},{"extension":[{"valueCode":"NL4","url":"http://hl7.org/fhir/StructureDefinition/humanname-assembly-order"}],"use":"usual","text":"BcnScTenAugTwentyOne UPGRADETEST","family":"UPGRADETEST","given":["BcnScTenAugTwentyOne"],"_family":{"extension":[{"valueString":"UpgradeTest","url":"http://hl7.org/fhir/StructureDefinition/humanname-own-name"}]}}],"gender":"female","birthDate":"2019-09-21","deceasedBoolean":false,"maritalStatus":{"text":"Single"}}
3{"resourceType":"Patient","id":"ezER-U3fAMP-WvI-Fc8V9wQ3","extension":[{"extension":[{"valueCoding":{"system":"http://terminology.hl7.org/CodeSystem/v3-NullFlavor","code":"UNK","display":"Unknown"},"url":"ombCategory"},{"valueString":"Unknown","url":"text"}],"url":"http://hl7.org/fhir/us/core/StructureDefinition/us-core-race"},{"extension":[{"valueString":"Unknown","url":"text"}],"url":"http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity"},{"valueCodeableConcept":{"coding":[{"system":"urn:oid:1.2.840.114350.1.13.520.3.7.10.698084.130.657370.334258","code":"male"}]},"url":"http://open.epic.com/FHIR/StructureDefinition/extension/legal-sex"},{"valueCodeableConcept":{"coding":[{"system":"urn:oid:1.2.840.114350.1.13.520.3.7.10.698084.130.657370.334258","code":"male"}]},"url":"http://open.epic.com/FHIR/StructureDefinition/extension/sex-for-clinical-use"},{"valueCode":"M","url":"http://hl7.org/fhir/us/core/StructureDefinition/us-core-birthsex"}],"identifier":[{"use":"usual","type":{"text":"EPIC"},"system":"urn:oid:1.2.840.114350.1.13.520.3.7.5.737384.0","value":"E9411"},{"use":"usual","type":{"text":"EXTERNAL"},"system":"urn:oid:1.2.840.114350.1.13.520.3.7.2.698084","value":"Z11522"},{"use":"usual","type":{"text":"FHIR"},"system":"http://open.epic.com/FHIR/StructureDefinition/patient-dstu2-fhir-id","value":"T2oDrcOUw0w.1ZUdthu24c7V95lTOTEOUPRqBqGn99KEB"},{"use":"usual","type":{"text":"FHIR STU3"},"system":"http://open.epic.com/FHIR/StructureDefinition/patient-fhir-id","value":"ezER-U3fAMP-WvI-Fc8V9wQ3"},{"use":"usual","type":{"text":"PAS"},"system":"urn:oid:2.16.840.1.113883.2.1.3.12.1.1","value":"2005452"},{"use":"usual","type":{"text":"INTERNAL"},"system":"urn:oid:1.2.840.114350.1.13.520.3.7.2.698084","value":" Z11522"}],"active":true,"name":[{"extension":[{"valueCode":"NL4","url":"http://hl7.org/fhir/StructureDefinition/humanname-assembly-order"}],"use":"official","text":"Fred TEST","family":"TEST","given":["Fred"],"_family":{"extension":[{"valueString":"Test","url":"http://hl7.org/fhir/StructureDefinition/humanname-own-name"}]}},{"extension":[{"valueCode":"NL4","url":"http://hl7.org/fhir/StructureDefinition/humanname-assembly-order"}],"use":"usual","text":"Fred TEST","family":"TEST","given":["Fred"],"_family":{"extension":[{"valueString":"Test","url":"http://hl7.org/fhir/StructureDefinition/humanname-own-name"}]}}],"telecom":[{"system":"phone","value":"07594 832748","use":"mobile"},{"system":"email","value":"fred@email.com"}],"gender":"male","birthDate":"1967-01-19","deceasedBoolean":false,"address":[{"use":"old","line":["123 Anywhere"],"city":"Bristol","postalCode":"BS1 6JY","country":"ENG"},{"use":"home","line":["123 Anywhere"],"city":"Bristol","postalCode":"BS1 6JY","country":"ENG","period":{"start":"2022-01-19"}}],"maritalStatus":{"text":"Single"},"communication":[{"language":{"coding":[{"system":"urn:ietf:bcp:47","code":"en","display":"English"}],"text":"English"},"preferred":true}]}
4import ndjson
5
6 with open('Patients.ndjson') as f:
7 data = ndjson.load(f)
8 return render_template('home.html', patient = data)
9{% for i in patient : %}
10{% for item, value in i.items(): %}
11 <tr>
12 <td>{{ item }}</td>
13 <td>{{ value }}</td>
14 </tr>
15 {% endfor %}
16{% endfor %}
17
ANSWER
Answered 2022-Feb-22 at 12:04See the section about variables for jinja2, you only need a small change:
main.py
1{"resourceType":"Patient","id":"ewnMwMK-UNvVvM.bakFSlkw3","extension":[{"extension":[{"valueCoding":{"system":"http://terminology.hl7.org/CodeSystem/v3-NullFlavor","code":"UNK","display":"Unknown"},"url":"ombCategory"},{"valueString":"Unknown","url":"text"}],"url":"http://hl7.org/fhir/us/core/StructureDefinition/us-core-race"},{"extension":[{"valueString":"Unknown","url":"text"}],"url":"http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity"},{"valueCodeableConcept":{"coding":[{"system":"urn:oid:1.2.840.114350.1.13.520.3.7.10.698084.130.657370.334258","code":"female"}]},"url":"http://open.epic.com/FHIR/StructureDefinition/extension/legal-sex"},{"valueCodeableConcept":{"coding":[{"system":"urn:oid:1.2.840.114350.1.13.520.3.7.10.698084.130.657370.334258","code":"female"}]},"url":"http://open.epic.com/FHIR/StructureDefinition/extension/sex-for-clinical-use"},{"valueCode":"F","url":"http://hl7.org/fhir/us/core/StructureDefinition/us-core-birthsex"}],"identifier":[{"use":"usual","type":{"text":"EPIC"},"system":"urn:oid:1.2.840.114350.1.13.520.3.7.5.737384.0","value":"E9254"},{"use":"usual","type":{"text":"EXTERNAL"},"system":"urn:oid:1.2.840.114350.1.13.520.3.7.2.698084","value":"Z11363"},{"use":"usual","type":{"text":"FHIR"},"system":"http://open.epic.com/FHIR/StructureDefinition/patient-dstu2-fhir-id","value":"TYO3ktvhYAUhbae7JuBwDdpyIbUZc8kZG.bMW2ZwVnwgB"},{"use":"usual","type":{"text":"FHIR STU3"},"system":"http://open.epic.com/FHIR/StructureDefinition/patient-fhir-id","value":"ewnMwMK-UNvVvM.bakFSlkw3"},{"use":"usual","type":{"text":"PAS"},"system":"urn:oid:2.16.840.1.113883.2.1.3.12.1.1","value":"2005294"},{"use":"usual","type":{"text":"INTERNAL"},"system":"urn:oid:1.2.840.114350.1.13.520.3.7.2.698084","value":" Z11363"}],"active":true,"name":[{"extension":[{"valueCode":"NL4","url":"http://hl7.org/fhir/StructureDefinition/humanname-assembly-order"}],"use":"official","text":"Test ADVANCEPREPTWO","family":"ADVANCEPREPTWO","given":["Test"],"_family":{"extension":[{"valueString":"Advancepreptwo","url":"http://hl7.org/fhir/StructureDefinition/humanname-own-name"}]}},{"extension":[{"valueCode":"NL4","url":"http://hl7.org/fhir/StructureDefinition/humanname-assembly-order"}],"use":"usual","text":"Test ADVANCEPREPTWO","family":"ADVANCEPREPTWO","given":["Test"],"_family":{"extension":[{"valueString":"Advancepreptwo","url":"http://hl7.org/fhir/StructureDefinition/humanname-own-name"}]}}],"gender":"female","birthDate":"2006-10-07","deceasedBoolean":false,"maritalStatus":{"text":"Single"}}
2{"resourceType":"Patient","id":"exU8JSL0p8npSw5g1QYAyOw3","extension":[{"extension":[{"valueCoding":{"system":"http://terminology.hl7.org/CodeSystem/v3-NullFlavor","code":"UNK","display":"Unknown"},"url":"ombCategory"},{"valueString":"Unknown","url":"text"}],"url":"http://hl7.org/fhir/us/core/StructureDefinition/us-core-race"},{"extension":[{"valueString":"Unknown","url":"text"}],"url":"http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity"},{"valueCodeableConcept":{"coding":[{"system":"urn:oid:1.2.840.114350.1.13.520.3.7.10.698084.130.657370.334258","code":"female"}]},"url":"http://open.epic.com/FHIR/StructureDefinition/extension/legal-sex"},{"valueCodeableConcept":{"coding":[{"system":"urn:oid:1.2.840.114350.1.13.520.3.7.10.698084.130.657370.334258","code":"female"}]},"url":"http://open.epic.com/FHIR/StructureDefinition/extension/sex-for-clinical-use"},{"valueCode":"F","url":"http://hl7.org/fhir/us/core/StructureDefinition/us-core-birthsex"}],"identifier":[{"use":"usual","type":{"text":"EPIC"},"system":"urn:oid:1.2.840.114350.1.13.520.3.7.5.737384.0","value":"E9340"},{"use":"usual","type":{"text":"EXTERNAL"},"system":"urn:oid:1.2.840.114350.1.13.520.3.7.2.698084","value":"Z11449"},{"use":"usual","type":{"text":"FHIR"},"system":"http://open.epic.com/FHIR/StructureDefinition/patient-dstu2-fhir-id","value":"TwzgMHMPt5OhnHkFA2H2DudL3FU8qcRZkZyn0F3extkAB"},{"use":"usual","type":{"text":"FHIR STU3"},"system":"http://open.epic.com/FHIR/StructureDefinition/patient-fhir-id","value":"exU8JSL0p8npSw5g1QYAyOw3"},{"use":"usual","type":{"text":"PAS"},"system":"urn:oid:2.16.840.1.113883.2.1.3.12.1.1","value":"2005380"},{"use":"usual","type":{"text":"INTERNAL"},"system":"urn:oid:1.2.840.114350.1.13.520.3.7.2.698084","value":" Z11449"}],"active":true,"name":[{"extension":[{"valueCode":"NL4","url":"http://hl7.org/fhir/StructureDefinition/humanname-assembly-order"}],"use":"official","text":"BcnScTenAugTwentyOne UPGRADETEST","family":"UPGRADETEST","given":["BcnScTenAugTwentyOne"],"_family":{"extension":[{"valueString":"UpgradeTest","url":"http://hl7.org/fhir/StructureDefinition/humanname-own-name"}]}},{"extension":[{"valueCode":"NL4","url":"http://hl7.org/fhir/StructureDefinition/humanname-assembly-order"}],"use":"usual","text":"BcnScTenAugTwentyOne UPGRADETEST","family":"UPGRADETEST","given":["BcnScTenAugTwentyOne"],"_family":{"extension":[{"valueString":"UpgradeTest","url":"http://hl7.org/fhir/StructureDefinition/humanname-own-name"}]}}],"gender":"female","birthDate":"2019-09-21","deceasedBoolean":false,"maritalStatus":{"text":"Single"}}
3{"resourceType":"Patient","id":"ezER-U3fAMP-WvI-Fc8V9wQ3","extension":[{"extension":[{"valueCoding":{"system":"http://terminology.hl7.org/CodeSystem/v3-NullFlavor","code":"UNK","display":"Unknown"},"url":"ombCategory"},{"valueString":"Unknown","url":"text"}],"url":"http://hl7.org/fhir/us/core/StructureDefinition/us-core-race"},{"extension":[{"valueString":"Unknown","url":"text"}],"url":"http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity"},{"valueCodeableConcept":{"coding":[{"system":"urn:oid:1.2.840.114350.1.13.520.3.7.10.698084.130.657370.334258","code":"male"}]},"url":"http://open.epic.com/FHIR/StructureDefinition/extension/legal-sex"},{"valueCodeableConcept":{"coding":[{"system":"urn:oid:1.2.840.114350.1.13.520.3.7.10.698084.130.657370.334258","code":"male"}]},"url":"http://open.epic.com/FHIR/StructureDefinition/extension/sex-for-clinical-use"},{"valueCode":"M","url":"http://hl7.org/fhir/us/core/StructureDefinition/us-core-birthsex"}],"identifier":[{"use":"usual","type":{"text":"EPIC"},"system":"urn:oid:1.2.840.114350.1.13.520.3.7.5.737384.0","value":"E9411"},{"use":"usual","type":{"text":"EXTERNAL"},"system":"urn:oid:1.2.840.114350.1.13.520.3.7.2.698084","value":"Z11522"},{"use":"usual","type":{"text":"FHIR"},"system":"http://open.epic.com/FHIR/StructureDefinition/patient-dstu2-fhir-id","value":"T2oDrcOUw0w.1ZUdthu24c7V95lTOTEOUPRqBqGn99KEB"},{"use":"usual","type":{"text":"FHIR STU3"},"system":"http://open.epic.com/FHIR/StructureDefinition/patient-fhir-id","value":"ezER-U3fAMP-WvI-Fc8V9wQ3"},{"use":"usual","type":{"text":"PAS"},"system":"urn:oid:2.16.840.1.113883.2.1.3.12.1.1","value":"2005452"},{"use":"usual","type":{"text":"INTERNAL"},"system":"urn:oid:1.2.840.114350.1.13.520.3.7.2.698084","value":" Z11522"}],"active":true,"name":[{"extension":[{"valueCode":"NL4","url":"http://hl7.org/fhir/StructureDefinition/humanname-assembly-order"}],"use":"official","text":"Fred TEST","family":"TEST","given":["Fred"],"_family":{"extension":[{"valueString":"Test","url":"http://hl7.org/fhir/StructureDefinition/humanname-own-name"}]}},{"extension":[{"valueCode":"NL4","url":"http://hl7.org/fhir/StructureDefinition/humanname-assembly-order"}],"use":"usual","text":"Fred TEST","family":"TEST","given":["Fred"],"_family":{"extension":[{"valueString":"Test","url":"http://hl7.org/fhir/StructureDefinition/humanname-own-name"}]}}],"telecom":[{"system":"phone","value":"07594 832748","use":"mobile"},{"system":"email","value":"fred@email.com"}],"gender":"male","birthDate":"1967-01-19","deceasedBoolean":false,"address":[{"use":"old","line":["123 Anywhere"],"city":"Bristol","postalCode":"BS1 6JY","country":"ENG"},{"use":"home","line":["123 Anywhere"],"city":"Bristol","postalCode":"BS1 6JY","country":"ENG","period":{"start":"2022-01-19"}}],"maritalStatus":{"text":"Single"},"communication":[{"language":{"coding":[{"system":"urn:ietf:bcp:47","code":"en","display":"English"}],"text":"English"},"preferred":true}]}
4import ndjson
5
6 with open('Patients.ndjson') as f:
7 data = ndjson.load(f)
8 return render_template('home.html', patient = data)
9{% for i in patient : %}
10{% for item, value in i.items(): %}
11 <tr>
12 <td>{{ item }}</td>
13 <td>{{ value }}</td>
14 </tr>
15 {% endfor %}
16{% endfor %}
17from flask import Flask, render_template
18import ndjson
19
20
21app = Flask(__name__)
22
23
24template = "tmp.html"
25
26
27@app.route('/')
28def main():
29 with open('patients.ndjson') as f:
30 patients = ndjson.load(f)
31
32 return render_template(template, patients=patients)
33
34
35
36if __name__ == '__main__':
37 app.run(debug=True)```
38
tmp.html
1{"resourceType":"Patient","id":"ewnMwMK-UNvVvM.bakFSlkw3","extension":[{"extension":[{"valueCoding":{"system":"http://terminology.hl7.org/CodeSystem/v3-NullFlavor","code":"UNK","display":"Unknown"},"url":"ombCategory"},{"valueString":"Unknown","url":"text"}],"url":"http://hl7.org/fhir/us/core/StructureDefinition/us-core-race"},{"extension":[{"valueString":"Unknown","url":"text"}],"url":"http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity"},{"valueCodeableConcept":{"coding":[{"system":"urn:oid:1.2.840.114350.1.13.520.3.7.10.698084.130.657370.334258","code":"female"}]},"url":"http://open.epic.com/FHIR/StructureDefinition/extension/legal-sex"},{"valueCodeableConcept":{"coding":[{"system":"urn:oid:1.2.840.114350.1.13.520.3.7.10.698084.130.657370.334258","code":"female"}]},"url":"http://open.epic.com/FHIR/StructureDefinition/extension/sex-for-clinical-use"},{"valueCode":"F","url":"http://hl7.org/fhir/us/core/StructureDefinition/us-core-birthsex"}],"identifier":[{"use":"usual","type":{"text":"EPIC"},"system":"urn:oid:1.2.840.114350.1.13.520.3.7.5.737384.0","value":"E9254"},{"use":"usual","type":{"text":"EXTERNAL"},"system":"urn:oid:1.2.840.114350.1.13.520.3.7.2.698084","value":"Z11363"},{"use":"usual","type":{"text":"FHIR"},"system":"http://open.epic.com/FHIR/StructureDefinition/patient-dstu2-fhir-id","value":"TYO3ktvhYAUhbae7JuBwDdpyIbUZc8kZG.bMW2ZwVnwgB"},{"use":"usual","type":{"text":"FHIR STU3"},"system":"http://open.epic.com/FHIR/StructureDefinition/patient-fhir-id","value":"ewnMwMK-UNvVvM.bakFSlkw3"},{"use":"usual","type":{"text":"PAS"},"system":"urn:oid:2.16.840.1.113883.2.1.3.12.1.1","value":"2005294"},{"use":"usual","type":{"text":"INTERNAL"},"system":"urn:oid:1.2.840.114350.1.13.520.3.7.2.698084","value":" Z11363"}],"active":true,"name":[{"extension":[{"valueCode":"NL4","url":"http://hl7.org/fhir/StructureDefinition/humanname-assembly-order"}],"use":"official","text":"Test ADVANCEPREPTWO","family":"ADVANCEPREPTWO","given":["Test"],"_family":{"extension":[{"valueString":"Advancepreptwo","url":"http://hl7.org/fhir/StructureDefinition/humanname-own-name"}]}},{"extension":[{"valueCode":"NL4","url":"http://hl7.org/fhir/StructureDefinition/humanname-assembly-order"}],"use":"usual","text":"Test ADVANCEPREPTWO","family":"ADVANCEPREPTWO","given":["Test"],"_family":{"extension":[{"valueString":"Advancepreptwo","url":"http://hl7.org/fhir/StructureDefinition/humanname-own-name"}]}}],"gender":"female","birthDate":"2006-10-07","deceasedBoolean":false,"maritalStatus":{"text":"Single"}}
2{"resourceType":"Patient","id":"exU8JSL0p8npSw5g1QYAyOw3","extension":[{"extension":[{"valueCoding":{"system":"http://terminology.hl7.org/CodeSystem/v3-NullFlavor","code":"UNK","display":"Unknown"},"url":"ombCategory"},{"valueString":"Unknown","url":"text"}],"url":"http://hl7.org/fhir/us/core/StructureDefinition/us-core-race"},{"extension":[{"valueString":"Unknown","url":"text"}],"url":"http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity"},{"valueCodeableConcept":{"coding":[{"system":"urn:oid:1.2.840.114350.1.13.520.3.7.10.698084.130.657370.334258","code":"female"}]},"url":"http://open.epic.com/FHIR/StructureDefinition/extension/legal-sex"},{"valueCodeableConcept":{"coding":[{"system":"urn:oid:1.2.840.114350.1.13.520.3.7.10.698084.130.657370.334258","code":"female"}]},"url":"http://open.epic.com/FHIR/StructureDefinition/extension/sex-for-clinical-use"},{"valueCode":"F","url":"http://hl7.org/fhir/us/core/StructureDefinition/us-core-birthsex"}],"identifier":[{"use":"usual","type":{"text":"EPIC"},"system":"urn:oid:1.2.840.114350.1.13.520.3.7.5.737384.0","value":"E9340"},{"use":"usual","type":{"text":"EXTERNAL"},"system":"urn:oid:1.2.840.114350.1.13.520.3.7.2.698084","value":"Z11449"},{"use":"usual","type":{"text":"FHIR"},"system":"http://open.epic.com/FHIR/StructureDefinition/patient-dstu2-fhir-id","value":"TwzgMHMPt5OhnHkFA2H2DudL3FU8qcRZkZyn0F3extkAB"},{"use":"usual","type":{"text":"FHIR STU3"},"system":"http://open.epic.com/FHIR/StructureDefinition/patient-fhir-id","value":"exU8JSL0p8npSw5g1QYAyOw3"},{"use":"usual","type":{"text":"PAS"},"system":"urn:oid:2.16.840.1.113883.2.1.3.12.1.1","value":"2005380"},{"use":"usual","type":{"text":"INTERNAL"},"system":"urn:oid:1.2.840.114350.1.13.520.3.7.2.698084","value":" Z11449"}],"active":true,"name":[{"extension":[{"valueCode":"NL4","url":"http://hl7.org/fhir/StructureDefinition/humanname-assembly-order"}],"use":"official","text":"BcnScTenAugTwentyOne UPGRADETEST","family":"UPGRADETEST","given":["BcnScTenAugTwentyOne"],"_family":{"extension":[{"valueString":"UpgradeTest","url":"http://hl7.org/fhir/StructureDefinition/humanname-own-name"}]}},{"extension":[{"valueCode":"NL4","url":"http://hl7.org/fhir/StructureDefinition/humanname-assembly-order"}],"use":"usual","text":"BcnScTenAugTwentyOne UPGRADETEST","family":"UPGRADETEST","given":["BcnScTenAugTwentyOne"],"_family":{"extension":[{"valueString":"UpgradeTest","url":"http://hl7.org/fhir/StructureDefinition/humanname-own-name"}]}}],"gender":"female","birthDate":"2019-09-21","deceasedBoolean":false,"maritalStatus":{"text":"Single"}}
3{"resourceType":"Patient","id":"ezER-U3fAMP-WvI-Fc8V9wQ3","extension":[{"extension":[{"valueCoding":{"system":"http://terminology.hl7.org/CodeSystem/v3-NullFlavor","code":"UNK","display":"Unknown"},"url":"ombCategory"},{"valueString":"Unknown","url":"text"}],"url":"http://hl7.org/fhir/us/core/StructureDefinition/us-core-race"},{"extension":[{"valueString":"Unknown","url":"text"}],"url":"http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity"},{"valueCodeableConcept":{"coding":[{"system":"urn:oid:1.2.840.114350.1.13.520.3.7.10.698084.130.657370.334258","code":"male"}]},"url":"http://open.epic.com/FHIR/StructureDefinition/extension/legal-sex"},{"valueCodeableConcept":{"coding":[{"system":"urn:oid:1.2.840.114350.1.13.520.3.7.10.698084.130.657370.334258","code":"male"}]},"url":"http://open.epic.com/FHIR/StructureDefinition/extension/sex-for-clinical-use"},{"valueCode":"M","url":"http://hl7.org/fhir/us/core/StructureDefinition/us-core-birthsex"}],"identifier":[{"use":"usual","type":{"text":"EPIC"},"system":"urn:oid:1.2.840.114350.1.13.520.3.7.5.737384.0","value":"E9411"},{"use":"usual","type":{"text":"EXTERNAL"},"system":"urn:oid:1.2.840.114350.1.13.520.3.7.2.698084","value":"Z11522"},{"use":"usual","type":{"text":"FHIR"},"system":"http://open.epic.com/FHIR/StructureDefinition/patient-dstu2-fhir-id","value":"T2oDrcOUw0w.1ZUdthu24c7V95lTOTEOUPRqBqGn99KEB"},{"use":"usual","type":{"text":"FHIR STU3"},"system":"http://open.epic.com/FHIR/StructureDefinition/patient-fhir-id","value":"ezER-U3fAMP-WvI-Fc8V9wQ3"},{"use":"usual","type":{"text":"PAS"},"system":"urn:oid:2.16.840.1.113883.2.1.3.12.1.1","value":"2005452"},{"use":"usual","type":{"text":"INTERNAL"},"system":"urn:oid:1.2.840.114350.1.13.520.3.7.2.698084","value":" Z11522"}],"active":true,"name":[{"extension":[{"valueCode":"NL4","url":"http://hl7.org/fhir/StructureDefinition/humanname-assembly-order"}],"use":"official","text":"Fred TEST","family":"TEST","given":["Fred"],"_family":{"extension":[{"valueString":"Test","url":"http://hl7.org/fhir/StructureDefinition/humanname-own-name"}]}},{"extension":[{"valueCode":"NL4","url":"http://hl7.org/fhir/StructureDefinition/humanname-assembly-order"}],"use":"usual","text":"Fred TEST","family":"TEST","given":["Fred"],"_family":{"extension":[{"valueString":"Test","url":"http://hl7.org/fhir/StructureDefinition/humanname-own-name"}]}}],"telecom":[{"system":"phone","value":"07594 832748","use":"mobile"},{"system":"email","value":"fred@email.com"}],"gender":"male","birthDate":"1967-01-19","deceasedBoolean":false,"address":[{"use":"old","line":["123 Anywhere"],"city":"Bristol","postalCode":"BS1 6JY","country":"ENG"},{"use":"home","line":["123 Anywhere"],"city":"Bristol","postalCode":"BS1 6JY","country":"ENG","period":{"start":"2022-01-19"}}],"maritalStatus":{"text":"Single"},"communication":[{"language":{"coding":[{"system":"urn:ietf:bcp:47","code":"en","display":"English"}],"text":"English"},"preferred":true}]}
4import ndjson
5
6 with open('Patients.ndjson') as f:
7 data = ndjson.load(f)
8 return render_template('home.html', patient = data)
9{% for i in patient : %}
10{% for item, value in i.items(): %}
11 <tr>
12 <td>{{ item }}</td>
13 <td>{{ value }}</td>
14 </tr>
15 {% endfor %}
16{% endfor %}
17from flask import Flask, render_template
18import ndjson
19
20
21app = Flask(__name__)
22
23
24template = "tmp.html"
25
26
27@app.route('/')
28def main():
29 with open('patients.ndjson') as f:
30 patients = ndjson.load(f)
31
32 return render_template(template, patients=patients)
33
34
35
36if __name__ == '__main__':
37 app.run(debug=True)```
38{% for patient in patients %}
39 <tr>
40 <td>{{ patient.id }}</td>
41 <td>{{ patient.birthDate }}</td>
42 <td>{{ patient.deceasedDateTime }}</td>
43 </tr></br>
44{% endfor %}
45
As an FYI, when loading an ndjson in python, it becomes a list of dicts. In your template, you need to iterate over the list, and for each dict item get the correct value by using the key as shown in my example.
You could use dict.items()
but this gives you all the key/value pairs unordered...
fe, using the following will print out the whole JSON for each line in the NDJSON:
1{"resourceType":"Patient","id":"ewnMwMK-UNvVvM.bakFSlkw3","extension":[{"extension":[{"valueCoding":{"system":"http://terminology.hl7.org/CodeSystem/v3-NullFlavor","code":"UNK","display":"Unknown"},"url":"ombCategory"},{"valueString":"Unknown","url":"text"}],"url":"http://hl7.org/fhir/us/core/StructureDefinition/us-core-race"},{"extension":[{"valueString":"Unknown","url":"text"}],"url":"http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity"},{"valueCodeableConcept":{"coding":[{"system":"urn:oid:1.2.840.114350.1.13.520.3.7.10.698084.130.657370.334258","code":"female"}]},"url":"http://open.epic.com/FHIR/StructureDefinition/extension/legal-sex"},{"valueCodeableConcept":{"coding":[{"system":"urn:oid:1.2.840.114350.1.13.520.3.7.10.698084.130.657370.334258","code":"female"}]},"url":"http://open.epic.com/FHIR/StructureDefinition/extension/sex-for-clinical-use"},{"valueCode":"F","url":"http://hl7.org/fhir/us/core/StructureDefinition/us-core-birthsex"}],"identifier":[{"use":"usual","type":{"text":"EPIC"},"system":"urn:oid:1.2.840.114350.1.13.520.3.7.5.737384.0","value":"E9254"},{"use":"usual","type":{"text":"EXTERNAL"},"system":"urn:oid:1.2.840.114350.1.13.520.3.7.2.698084","value":"Z11363"},{"use":"usual","type":{"text":"FHIR"},"system":"http://open.epic.com/FHIR/StructureDefinition/patient-dstu2-fhir-id","value":"TYO3ktvhYAUhbae7JuBwDdpyIbUZc8kZG.bMW2ZwVnwgB"},{"use":"usual","type":{"text":"FHIR STU3"},"system":"http://open.epic.com/FHIR/StructureDefinition/patient-fhir-id","value":"ewnMwMK-UNvVvM.bakFSlkw3"},{"use":"usual","type":{"text":"PAS"},"system":"urn:oid:2.16.840.1.113883.2.1.3.12.1.1","value":"2005294"},{"use":"usual","type":{"text":"INTERNAL"},"system":"urn:oid:1.2.840.114350.1.13.520.3.7.2.698084","value":" Z11363"}],"active":true,"name":[{"extension":[{"valueCode":"NL4","url":"http://hl7.org/fhir/StructureDefinition/humanname-assembly-order"}],"use":"official","text":"Test ADVANCEPREPTWO","family":"ADVANCEPREPTWO","given":["Test"],"_family":{"extension":[{"valueString":"Advancepreptwo","url":"http://hl7.org/fhir/StructureDefinition/humanname-own-name"}]}},{"extension":[{"valueCode":"NL4","url":"http://hl7.org/fhir/StructureDefinition/humanname-assembly-order"}],"use":"usual","text":"Test ADVANCEPREPTWO","family":"ADVANCEPREPTWO","given":["Test"],"_family":{"extension":[{"valueString":"Advancepreptwo","url":"http://hl7.org/fhir/StructureDefinition/humanname-own-name"}]}}],"gender":"female","birthDate":"2006-10-07","deceasedBoolean":false,"maritalStatus":{"text":"Single"}}
2{"resourceType":"Patient","id":"exU8JSL0p8npSw5g1QYAyOw3","extension":[{"extension":[{"valueCoding":{"system":"http://terminology.hl7.org/CodeSystem/v3-NullFlavor","code":"UNK","display":"Unknown"},"url":"ombCategory"},{"valueString":"Unknown","url":"text"}],"url":"http://hl7.org/fhir/us/core/StructureDefinition/us-core-race"},{"extension":[{"valueString":"Unknown","url":"text"}],"url":"http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity"},{"valueCodeableConcept":{"coding":[{"system":"urn:oid:1.2.840.114350.1.13.520.3.7.10.698084.130.657370.334258","code":"female"}]},"url":"http://open.epic.com/FHIR/StructureDefinition/extension/legal-sex"},{"valueCodeableConcept":{"coding":[{"system":"urn:oid:1.2.840.114350.1.13.520.3.7.10.698084.130.657370.334258","code":"female"}]},"url":"http://open.epic.com/FHIR/StructureDefinition/extension/sex-for-clinical-use"},{"valueCode":"F","url":"http://hl7.org/fhir/us/core/StructureDefinition/us-core-birthsex"}],"identifier":[{"use":"usual","type":{"text":"EPIC"},"system":"urn:oid:1.2.840.114350.1.13.520.3.7.5.737384.0","value":"E9340"},{"use":"usual","type":{"text":"EXTERNAL"},"system":"urn:oid:1.2.840.114350.1.13.520.3.7.2.698084","value":"Z11449"},{"use":"usual","type":{"text":"FHIR"},"system":"http://open.epic.com/FHIR/StructureDefinition/patient-dstu2-fhir-id","value":"TwzgMHMPt5OhnHkFA2H2DudL3FU8qcRZkZyn0F3extkAB"},{"use":"usual","type":{"text":"FHIR STU3"},"system":"http://open.epic.com/FHIR/StructureDefinition/patient-fhir-id","value":"exU8JSL0p8npSw5g1QYAyOw3"},{"use":"usual","type":{"text":"PAS"},"system":"urn:oid:2.16.840.1.113883.2.1.3.12.1.1","value":"2005380"},{"use":"usual","type":{"text":"INTERNAL"},"system":"urn:oid:1.2.840.114350.1.13.520.3.7.2.698084","value":" Z11449"}],"active":true,"name":[{"extension":[{"valueCode":"NL4","url":"http://hl7.org/fhir/StructureDefinition/humanname-assembly-order"}],"use":"official","text":"BcnScTenAugTwentyOne UPGRADETEST","family":"UPGRADETEST","given":["BcnScTenAugTwentyOne"],"_family":{"extension":[{"valueString":"UpgradeTest","url":"http://hl7.org/fhir/StructureDefinition/humanname-own-name"}]}},{"extension":[{"valueCode":"NL4","url":"http://hl7.org/fhir/StructureDefinition/humanname-assembly-order"}],"use":"usual","text":"BcnScTenAugTwentyOne UPGRADETEST","family":"UPGRADETEST","given":["BcnScTenAugTwentyOne"],"_family":{"extension":[{"valueString":"UpgradeTest","url":"http://hl7.org/fhir/StructureDefinition/humanname-own-name"}]}}],"gender":"female","birthDate":"2019-09-21","deceasedBoolean":false,"maritalStatus":{"text":"Single"}}
3{"resourceType":"Patient","id":"ezER-U3fAMP-WvI-Fc8V9wQ3","extension":[{"extension":[{"valueCoding":{"system":"http://terminology.hl7.org/CodeSystem/v3-NullFlavor","code":"UNK","display":"Unknown"},"url":"ombCategory"},{"valueString":"Unknown","url":"text"}],"url":"http://hl7.org/fhir/us/core/StructureDefinition/us-core-race"},{"extension":[{"valueString":"Unknown","url":"text"}],"url":"http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity"},{"valueCodeableConcept":{"coding":[{"system":"urn:oid:1.2.840.114350.1.13.520.3.7.10.698084.130.657370.334258","code":"male"}]},"url":"http://open.epic.com/FHIR/StructureDefinition/extension/legal-sex"},{"valueCodeableConcept":{"coding":[{"system":"urn:oid:1.2.840.114350.1.13.520.3.7.10.698084.130.657370.334258","code":"male"}]},"url":"http://open.epic.com/FHIR/StructureDefinition/extension/sex-for-clinical-use"},{"valueCode":"M","url":"http://hl7.org/fhir/us/core/StructureDefinition/us-core-birthsex"}],"identifier":[{"use":"usual","type":{"text":"EPIC"},"system":"urn:oid:1.2.840.114350.1.13.520.3.7.5.737384.0","value":"E9411"},{"use":"usual","type":{"text":"EXTERNAL"},"system":"urn:oid:1.2.840.114350.1.13.520.3.7.2.698084","value":"Z11522"},{"use":"usual","type":{"text":"FHIR"},"system":"http://open.epic.com/FHIR/StructureDefinition/patient-dstu2-fhir-id","value":"T2oDrcOUw0w.1ZUdthu24c7V95lTOTEOUPRqBqGn99KEB"},{"use":"usual","type":{"text":"FHIR STU3"},"system":"http://open.epic.com/FHIR/StructureDefinition/patient-fhir-id","value":"ezER-U3fAMP-WvI-Fc8V9wQ3"},{"use":"usual","type":{"text":"PAS"},"system":"urn:oid:2.16.840.1.113883.2.1.3.12.1.1","value":"2005452"},{"use":"usual","type":{"text":"INTERNAL"},"system":"urn:oid:1.2.840.114350.1.13.520.3.7.2.698084","value":" Z11522"}],"active":true,"name":[{"extension":[{"valueCode":"NL4","url":"http://hl7.org/fhir/StructureDefinition/humanname-assembly-order"}],"use":"official","text":"Fred TEST","family":"TEST","given":["Fred"],"_family":{"extension":[{"valueString":"Test","url":"http://hl7.org/fhir/StructureDefinition/humanname-own-name"}]}},{"extension":[{"valueCode":"NL4","url":"http://hl7.org/fhir/StructureDefinition/humanname-assembly-order"}],"use":"usual","text":"Fred TEST","family":"TEST","given":["Fred"],"_family":{"extension":[{"valueString":"Test","url":"http://hl7.org/fhir/StructureDefinition/humanname-own-name"}]}}],"telecom":[{"system":"phone","value":"07594 832748","use":"mobile"},{"system":"email","value":"fred@email.com"}],"gender":"male","birthDate":"1967-01-19","deceasedBoolean":false,"address":[{"use":"old","line":["123 Anywhere"],"city":"Bristol","postalCode":"BS1 6JY","country":"ENG"},{"use":"home","line":["123 Anywhere"],"city":"Bristol","postalCode":"BS1 6JY","country":"ENG","period":{"start":"2022-01-19"}}],"maritalStatus":{"text":"Single"},"communication":[{"language":{"coding":[{"system":"urn:ietf:bcp:47","code":"en","display":"English"}],"text":"English"},"preferred":true}]}
4import ndjson
5
6 with open('Patients.ndjson') as f:
7 data = ndjson.load(f)
8 return render_template('home.html', patient = data)
9{% for i in patient : %}
10{% for item, value in i.items(): %}
11 <tr>
12 <td>{{ item }}</td>
13 <td>{{ value }}</td>
14 </tr>
15 {% endfor %}
16{% endfor %}
17from flask import Flask, render_template
18import ndjson
19
20
21app = Flask(__name__)
22
23
24template = "tmp.html"
25
26
27@app.route('/')
28def main():
29 with open('patients.ndjson') as f:
30 patients = ndjson.load(f)
31
32 return render_template(template, patients=patients)
33
34
35
36if __name__ == '__main__':
37 app.run(debug=True)```
38{% for patient in patients %}
39 <tr>
40 <td>{{ patient.id }}</td>
41 <td>{{ patient.birthDate }}</td>
42 <td>{{ patient.deceasedDateTime }}</td>
43 </tr></br>
44{% endfor %}
45{% for patient in patients %}
46 {% for key,val in patient.items() %}
47 {{ key }}: {{val}}</br>
48 {% endfor %}
49{% endfor %}
50
QUESTION
Incoming call notification - Android/iOS
Asked 2022-Jan-28 at 00:35I am developing a voip based phone call app specially for video conferencing type calls. Everything works via normal push notifications.
how do I show incoming call screen with sound e.g.
I am trying to implement - https://developer.android.com/guide/topics/connectivity/telecom/selfManaged not sure if I am in the right direction.
Note: I don't want to interrupt/intercept normal phone calls.
ANSWER
Answered 2022-Jan-28 at 00:35I have managed to implement this using combination of push notification, broadcast receiver, alarm service, setting window flags on activity with "FullScreenIntent".
- "OnMessageReceived" set an alarm for x seconds (500ms) with Broadcast receiver
- in receiver setup MainActivity intent and set flags "NewTask" and "frombackground"
- In MainActivity - override "OnNewIntent", set the window flags
Window.AddFlags(WindowManagerFlags.KeepScreenOn); Window.AddFlags(WindowManagerFlags.DismissKeyguard); Window.AddFlags(WindowManagerFlags.ShowWhenLocked); Window.AddFlags(WindowManagerFlags.TurnScreenOn); Window.AddFlags(WindowManagerFlags.Fullscreen);
this will open the app in fullscreen and can be routed to appropriate page for custom UI
QUESTION
How to get the phone number and SIM card slot for the current device, on the callback of onCallAdded?
Asked 2022-Jan-26 at 09:29I'm working on an app that implements InCallService, so it can handle phone calls
The problemOn devices with multi-SIM, I need to show information of which SIM and associated phone number is used (of the current device).
Thing is, I can't find where to get this information.
What I've foundGiven that I reach a function like onCallAdded, I get an instance of Call class, so I need to associate something I get from there, to a sim slot and phone number.
Using
call.getDetails().getHandle()
, I can get a Uri consisting only the phone number of the other person that called (who called the current user, or who the current user has called).I can iterate over all SIM cards, but can't find what I can use to map between them and the current call:
1final TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
2final SubscriptionManager subscriptionManager = SubscriptionManager.from(context);
3for (final SubscriptionInfo subscriptionInfo : subscriptionManager.getActiveSubscriptionInfoList()) {
4 final TelephonyManager subscriptionId = telephonyManager.createForSubscriptionId(subscriptionInfo.getSubscriptionId());
5}
6
There was an old code that doesn't work anymore that uses
call.getDetails().getAccountHandle().getId()
andSubscriptionManager.from(context)getActiveSubscriptionInfoList().getActiveSubscriptionInfoList()
.I think I can use
telephonyManager.getSubscriptionId(callDetails.getAccountHandle())
, but it requires API 30, which is quite new...
Given a phone call that I get from this callback (and probably others), how can I get the associated SIM slot and phone number of it?
I prefer to know how to do it for as wide range of Android versions as possible, because InCallService is from API 23... It should be possible before API 30, right?
ANSWER
Answered 2022-Jan-26 at 09:29Use call.getDetails().getAccountHandle()
to get PhoneAccountHandle.
Then use TelecomManager.getPhoneAccount() to get PhoneAccount instance.
Permission Manifest.permission.READ_PHONE_NUMBERS
is needed for applications targeting API level 31+.
Disclaimer: I am no Android expert, so please do validate my thoughts.
EDIT: So solution for both before API 30 and from API 30 could be as such:
1final TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
2final SubscriptionManager subscriptionManager = SubscriptionManager.from(context);
3for (final SubscriptionInfo subscriptionInfo : subscriptionManager.getActiveSubscriptionInfoList()) {
4 final TelephonyManager subscriptionId = telephonyManager.createForSubscriptionId(subscriptionInfo.getSubscriptionId());
5}
6@RequiresApi(Build.VERSION_CODES.M)
7fun handleCall(context: Context, call: Call) {
8 var foundAndSetSimDetails = false
9 val callDetailsAccountHandle = callDetails.accountHandle
10 val subscriptionManager = context
11 .getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE) as SubscriptionManager
12 val telephonyManager =
13 context.getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager
14 val telecomManager =
15 context.getSystemService(Context.TELECOM_SERVICE) as TelecomManager
16 val hasReadPhoneStatePermission =
17 ActivityCompat.checkSelfPermission(context, Manifest.permission.READ_PHONE_STATE) == android.content.pm.PackageManager.PERMISSION_GRANTED
18 val phoneAccount = telecomManager.getPhoneAccount(callDetailsAccountHandle)
19 //TODO when targeting API 31, we might need to check for a new permission here, of READ_PHONE_NUMBERS
20 //find SIM by phone account
21 if (!foundAndSetSimDetails && phoneAccount != null && hasReadPhoneStatePermission) {
22 val callCapablePhoneAccounts = telecomManager.callCapablePhoneAccounts
23 run {
24 callCapablePhoneAccounts?.forEachIndexed { index, phoneAccountHandle ->
25 if (phoneAccountHandle != callDetailsAccountHandle)
26 return@forEachIndexed
27 if (!phoneAccount.hasCapabilities(PhoneAccount.CAPABILITY_SIM_SUBSCRIPTION))
28 return@run
29 //found the sim card index
30 simName = phoneAccount.label?.toString().orEmpty()
31 simIndex = index + 1
32 foundAndSetSimDetails = true
33 return@run
34 }
35 }
36 }
37 //find SIM by subscription ID
38 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && hasReadPhoneStatePermission) {
39 try {
40 val callSubscriptionId: Int =
41 telephonyManager.getSubscriptionId(callDetailsAccountHandle!!)
42 for (subscriptionInfo: SubscriptionInfo in subscriptionManager.activeSubscriptionInfoList) {
43 val activeSubscriptionId: Int = subscriptionInfo.subscriptionId
44 if (activeSubscriptionId == callSubscriptionId) {
45 setSimDetails(telephonyManager, subscriptionInfo)
46 foundAndSetSimDetails = true
47 break
48 }
49 }
50 } catch (e: Throwable) {
51 e.printStackTrace()
52 }
53 }
54 //find SIM by phone number
55 if (!foundAndSetSimDetails && hasReadPhoneStatePermission) {
56 try {
57 val simPhoneNumber: String? = phoneAccount?.address?.schemeSpecificPart
58 if (!simPhoneNumber.isNullOrBlank()) {
59 for (subscriptionInfo in subscriptionManager.activeSubscriptionInfoList) {
60 if (simPhoneNumber == subscriptionInfo.number) {
61 setSimDetails(telephonyManager, subscriptionInfo)
62 foundAndSetSimDetails = true
63 break
64 }
65 }
66 if (!foundAndSetSimDetails)
67 }
68 } catch (e: Throwable) {
69 e.printStackTrace()
70 }
71 }
72
73 private fun setSimDetails(telephonyManager: TelephonyManager, subscriptionInfo: SubscriptionInfo) {
74 var foundSimName: String? = null
75 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
76 val telephonyManagerForSubscriptionId =
77 telephonyManager.createForSubscriptionId(subscriptionInfo.subscriptionId)
78 foundSimName = telephonyManagerForSubscriptionId.simOperatorName
79 }
80 if (foundSimName.isNullOrBlank())
81 foundSimName = subscriptionInfo.carrierName?.toString()
82 simName = if (foundSimName.isNullOrBlank())
83 ""
84 else foundSimName
85 simIndex = subscriptionInfo.simSlotIndex + 1
86 }
87
QUESTION
How do I convert an HTML table into JSON in Logic Apps
Asked 2022-Jan-24 at 12:27I am building a Logic App to deal with Call Before You Dig email replies we receive. The first email is a confirmation email and it includes a table indicating which utility providers have been notified. I would like to add the contents of that table to an excel spreadsheet and add our own reference number in the process. I found a possible solution in this answer which was taken from John Dyer's Blog.
1 var data = [];
2
3 // first row needs to be headers
4 var headers = [];
5 for (var i=0; i<table.rows[0].cells.length; i++) {
6 headers[i] = table.rows[0].cells[i].innerHTML.toLowerCase().replace(/ /gi,'');
7 }
8
9 // go through cells
10 for (var i=1; i<table.rows.length; i++) {
11
12 var tableRow = table.rows[i];
13 var rowData = {};
14
15 for (var j=0; j<tableRow.cells.length; j++) {
16
17 rowData[ headers[j] ] = tableRow.cells[j].innerHTML;
18
19 }
20
21 data.push(rowData);
22 }
23
24 return data;
25}
26
I tried to use this code in a Azure Function but it was getting to complicated for me when it made me download VS. I could not find a way to just add the code in the portal. I installed VS but it started to get beyond me very quickly.
I found an online converter and used it to convert the code into C++ so I could maybe use it in a .net function.
1 var data = [];
2
3 // first row needs to be headers
4 var headers = [];
5 for (var i=0; i<table.rows[0].cells.length; i++) {
6 headers[i] = table.rows[0].cells[i].innerHTML.toLowerCase().replace(/ /gi,'');
7 }
8
9 // go through cells
10 for (var i=1; i<table.rows.length; i++) {
11
12 var tableRow = table.rows[i];
13 var rowData = {};
14
15 for (var j=0; j<tableRow.cells.length; j++) {
16
17 rowData[ headers[j] ] = tableRow.cells[j].innerHTML;
18
19 }
20
21 data.push(rowData);
22 }
23
24 return data;
25}
26#include <stdio.h>
27int main()
28{
29 printf("function tableToJson(table) {
30 var data = [];
31
32 // first row needs to be headers
33 var headers = [];
34 for (var i=0; i<table.rows[0].cells.length; i++) {
35 headers[i] = table.rows[0].cells[i].innerHTML.toLowerCase().replace(/ /gi,'');
36 }
37
38 // go through cells
39 for (var i=1; i<table.rows.length; i++) {
40
41 var tableRow = table.rows[i];
42 var rowData = {};
43
44 for (var j=0; j<tableRow.cells.length; j++) {
45
46 rowData[ headers[j] ] = tableRow.cells[j].innerHTML;
47
48 }
49
50 data.push(rowData);
51 }
52
53 return data;
54}\n");
55 return 0;
56}
57
I have used two compose actions to trim the mails content down to just the table in question:
1 var data = [];
2
3 // first row needs to be headers
4 var headers = [];
5 for (var i=0; i<table.rows[0].cells.length; i++) {
6 headers[i] = table.rows[0].cells[i].innerHTML.toLowerCase().replace(/ /gi,'');
7 }
8
9 // go through cells
10 for (var i=1; i<table.rows.length; i++) {
11
12 var tableRow = table.rows[i];
13 var rowData = {};
14
15 for (var j=0; j<tableRow.cells.length; j++) {
16
17 rowData[ headers[j] ] = tableRow.cells[j].innerHTML;
18
19 }
20
21 data.push(rowData);
22 }
23
24 return data;
25}
26#include <stdio.h>
27int main()
28{
29 printf("function tableToJson(table) {
30 var data = [];
31
32 // first row needs to be headers
33 var headers = [];
34 for (var i=0; i<table.rows[0].cells.length; i++) {
35 headers[i] = table.rows[0].cells[i].innerHTML.toLowerCase().replace(/ /gi,'');
36 }
37
38 // go through cells
39 for (var i=1; i<table.rows.length; i++) {
40
41 var tableRow = table.rows[i];
42 var rowData = {};
43
44 for (var j=0; j<tableRow.cells.length; j++) {
45
46 rowData[ headers[j] ] = tableRow.cells[j].innerHTML;
47
48 }
49
50 data.push(rowData);
51 }
52
53 return data;
54}\n");
55 return 0;
56}
57<table class="MsoNormalTable" border="1" cellspacing="0" cellpadding="0" width="100%" style="width:100.0%; border-collapse:collapse; border:none">
58 <tbody>
59 <tr>
60 <td colspan="3" valign="top" style="border:solid gray 1.0pt; background:#9CCC6B; padding:3.75pt .75pt 3.75pt 3.75pt">
61 <p class="MsoNormal">
62 <b>
63 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black">MEMBERS NOTIFIED: The following owners of underground infrastructure in the area of your excavation site have been notified.</span>
64 </b>
65 </p>
66 </td>
67 </tr>
68 <tr>
69 <td width="50%" valign="top" style="width:50.0%; border-top:none; border-left:solid gray 1.0pt; border-bottom:solid gray 1.0pt; border-right:none; background:#9CCC6B; padding:3.75pt .75pt 3.75pt 3.75pt">
70 <p class="MsoNormal" align="center" style="text-align:center">
71 <b>
72 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black">Member name</span>
73 </b>
74 </p>
75 </td>
76 <td width="25%" valign="top" style="width:25.0%; border-top:none; border-left:solid gray 1.0pt; border-bottom:solid gray 1.0pt; border-right:none; background:#9CCC6B; padding:3.75pt .75pt 3.75pt 3.75pt">
77 <p class="MsoNormal" align="center" style="text-align:center">
78 <b>
79 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black">Station Code</span>
80 </b>
81 </p>
82 </td>
83 <td width="25%" valign="top" style="width:25.0%; border:solid gray 1.0pt; border-top:none; background:#9CCC6B; padding:3.75pt .75pt 3.75pt 3.75pt">
84 <p class="MsoNormal" align="center" style="text-align:center">
85 <b>
86 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black">Initial Status</span>
87 </b>
88 </p>
89 </td>
90 </tr>
91 <tr>
92 <td valign="top" style="border:none; border-left:solid gray 1.0pt; padding:3.75pt .75pt 3.75pt 3.75pt">
93 <p class="MsoNormal" align="center" style="text-align:center">
94 <span class="value">
95 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif">G-TEL FOR ENBRIDGE GAS (LEGACY UNION GAS) (ENOW01)</span>
96 </span>
97 <b>
98 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black"></span>
99 </b>
100 </p>
101 </td>
102 <td valign="top" style="border:none; border-left:solid gray 1.0pt; padding:3.75pt .75pt 3.75pt 3.75pt">
103 <p class="MsoNormal" align="center" style="text-align:center">
104 <span class="value">
105 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif">ENOW01</span>
106 </span>
107 <b>
108 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black"></span>
109 </b>
110 </p>
111 </td>
112 <td valign="top" style="border-top:none; border-left:solid gray 1.0pt; border-bottom:none; border-right:solid gray 1.0pt; padding:3.75pt .75pt 3.75pt 3.75pt">
113 <p class="MsoNormal" align="center" style="text-align:center">
114 <span class="value">
115 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif">Notification sent</span>
116 </span>
117 <b>
118 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black"></span>
119 </b>
120 </p>
121 </td>
122 </tr>
123 <tr>
124 <td valign="top" style="border:none; border-left:solid gray 1.0pt; padding:3.75pt .75pt 3.75pt 3.75pt">
125 <p class="MsoNormal" align="center" style="text-align:center">
126 <span class="value">
127 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif">CITY OF STRATFORD (STRATWS01)</span>
128 </span>
129 <b>
130 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black"></span>
131 </b>
132 </p>
133 </td>
134 <td valign="top" style="border:none; border-left:solid gray 1.0pt; padding:3.75pt .75pt 3.75pt 3.75pt">
135 <p class="MsoNormal" align="center" style="text-align:center">
136 <span class="value">
137 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif">STRATWS01</span>
138 </span>
139 <b>
140 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black"></span>
141 </b>
142 </p>
143 </td>
144 <td valign="top" style="border-top:none; border-left:solid gray 1.0pt; border-bottom:none; border-right:solid gray 1.0pt; padding:3.75pt .75pt 3.75pt 3.75pt">
145 <p class="MsoNormal" align="center" style="text-align:center">
146 <span class="value">
147 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif">Notification sent</span>
148 </span>
149 <b>
150 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black"></span>
151 </b>
152 </p>
153 </td>
154 </tr>
155 <tr>
156 <td valign="top" style="border:none; border-left:solid gray 1.0pt; padding:3.75pt .75pt 3.75pt 3.75pt">
157 <p class="MsoNormal" align="center" style="text-align:center">
158 <span class="value">
159 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif">FESTIVAL HYDRO (LOCAL HYDRO) (FESTH01)</span>
160 </span>
161 <b>
162 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black"></span>
163 </b>
164 </p>
165 </td>
166 <td valign="top" style="border:none; border-left:solid gray 1.0pt; padding:3.75pt .75pt 3.75pt 3.75pt">
167 <p class="MsoNormal" align="center" style="text-align:center">
168 <span class="value">
169 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif">FESTH01</span>
170 </span>
171 <b>
172 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black"></span>
173 </b>
174 </p>
175 </td>
176 <td valign="top" style="border-top:none; border-left:solid gray 1.0pt; border-bottom:none; border-right:solid gray 1.0pt; padding:3.75pt .75pt 3.75pt 3.75pt">
177 <p class="MsoNormal" align="center" style="text-align:center">
178 <span class="value">
179 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif">Notification sent</span>
180 </span>
181 <b>
182 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black"></span>
183 </b>
184 </p>
185 </td>
186 </tr>
187 <tr>
188 <td valign="top" style="border:none; border-left:solid gray 1.0pt; padding:3.75pt .75pt 3.75pt 3.75pt">
189 <p class="MsoNormal" align="center" style="text-align:center">
190 <span class="value">
191 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif">WIGHTMAN TELECOM - FIBRE - LIMITED (WT01)</span>
192 </span>
193 <b>
194 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black"></span>
195 </b>
196 </p>
197 </td>
198 <td valign="top" style="border:none; border-left:solid gray 1.0pt; padding:3.75pt .75pt 3.75pt 3.75pt">
199 <p class="MsoNormal" align="center" style="text-align:center">
200 <span class="value">
201 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif">WT01</span>
202 </span>
203 <b>
204 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black"></span>
205 </b>
206 </p>
207 </td>
208 <td valign="top" style="border-top:none; border-left:solid gray 1.0pt; border-bottom:none; border-right:solid gray 1.0pt; padding:3.75pt .75pt 3.75pt 3.75pt">
209 <p class="MsoNormal" align="center" style="text-align:center">
210 <span class="value">
211 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif">Notification sent</span>
212 </span>
213 <b>
214 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black"></span>
215 </b>
216 </p>
217 </td>
218 </tr>
219 <tr>
220 <td valign="top" style="border:none; border-left:solid gray 1.0pt; padding:3.75pt .75pt 3.75pt 3.75pt">
221 <p class="MsoNormal" align="center" style="text-align:center">
222 <span class="value">
223 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif">CLI FOR ROGERS (ROGWAT01)</span>
224 </span>
225 <b>
226 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black"></span>
227 </b>
228 </p>
229 </td>
230 <td valign="top" style="border:none; border-left:solid gray 1.0pt; padding:3.75pt .75pt 3.75pt 3.75pt">
231 <p class="MsoNormal" align="center" style="text-align:center">
232 <span class="value">
233 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif">ROGWAT01</span>
234 </span>
235 <b>
236 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black"></span>
237 </b>
238 </p>
239 </td>
240 <td valign="top" style="border-top:none; border-left:solid gray 1.0pt; border-bottom:none; border-right:solid gray 1.0pt; padding:3.75pt .75pt 3.75pt 3.75pt">
241 <p class="MsoNormal" align="center" style="text-align:center">
242 <span class="value">
243 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif">Cleared</span>
244 </span>
245 <b>
246 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black"></span>
247 </b>
248 </p>
249 </td>
250 </tr>
251 <tr>
252 <td valign="top" style="border-top:none; border-left:solid gray 1.0pt; border-bottom:solid gray 1.0pt; border-right:none; padding:3.75pt .75pt 3.75pt 3.75pt">
253 <p class="MsoNormal" align="center" style="text-align:center">
254 <span class="value">
255 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif">G-TEL FOR BELL CANADA (BCOW01)</span>
256 </span>
257 <b>
258 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black"></span>
259 </b>
260 </p>
261 </td>
262 <td valign="top" style="border-top:none; border-left:solid gray 1.0pt; border-bottom:solid gray 1.0pt; border-right:none; padding:3.75pt .75pt 3.75pt 3.75pt">
263 <p class="MsoNormal" align="center" style="text-align:center">
264 <span class="value">
265 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif">BCOW01</span>
266 </span>
267 <b>
268 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black"></span>
269 </b>
270 </p>
271 </td>
272 <td valign="top" style="border:solid gray 1.0pt; border-top:none; padding:3.75pt .75pt 3.75pt 3.75pt">
273 <p class="MsoNormal" align="center" style="text-align:center">
274 <span class="value">
275 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif">Notification sent</span>
276 </span>
277 <b>
278 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black"></span>
279 </b>
280 </p>
281 </td>
282 </tr>
283 </tbody>
284</table>
This HTML becomes the input to Azure Function action and the Function I created using the C++ code that was output by the conversion and referenced above.
I am getting an Internal Server Error 500 on the output.
I am hoping someone can point me in the right direction to solve this. I have obviously done something wrong!
ANSWER
Answered 2022-Jan-24 at 12:27I hope I'm on the right track but this code below (although quite specific to your use case) will read the HTML table and return a JSON representation of the data.
Just create a new Azure Function in .NET called ConvertHtmlTableToJson
and paste it in.
1 var data = [];
2
3 // first row needs to be headers
4 var headers = [];
5 for (var i=0; i<table.rows[0].cells.length; i++) {
6 headers[i] = table.rows[0].cells[i].innerHTML.toLowerCase().replace(/ /gi,'');
7 }
8
9 // go through cells
10 for (var i=1; i<table.rows.length; i++) {
11
12 var tableRow = table.rows[i];
13 var rowData = {};
14
15 for (var j=0; j<tableRow.cells.length; j++) {
16
17 rowData[ headers[j] ] = tableRow.cells[j].innerHTML;
18
19 }
20
21 data.push(rowData);
22 }
23
24 return data;
25}
26#include <stdio.h>
27int main()
28{
29 printf("function tableToJson(table) {
30 var data = [];
31
32 // first row needs to be headers
33 var headers = [];
34 for (var i=0; i<table.rows[0].cells.length; i++) {
35 headers[i] = table.rows[0].cells[i].innerHTML.toLowerCase().replace(/ /gi,'');
36 }
37
38 // go through cells
39 for (var i=1; i<table.rows.length; i++) {
40
41 var tableRow = table.rows[i];
42 var rowData = {};
43
44 for (var j=0; j<tableRow.cells.length; j++) {
45
46 rowData[ headers[j] ] = tableRow.cells[j].innerHTML;
47
48 }
49
50 data.push(rowData);
51 }
52
53 return data;
54}\n");
55 return 0;
56}
57<table class="MsoNormalTable" border="1" cellspacing="0" cellpadding="0" width="100%" style="width:100.0%; border-collapse:collapse; border:none">
58 <tbody>
59 <tr>
60 <td colspan="3" valign="top" style="border:solid gray 1.0pt; background:#9CCC6B; padding:3.75pt .75pt 3.75pt 3.75pt">
61 <p class="MsoNormal">
62 <b>
63 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black">MEMBERS NOTIFIED: The following owners of underground infrastructure in the area of your excavation site have been notified.</span>
64 </b>
65 </p>
66 </td>
67 </tr>
68 <tr>
69 <td width="50%" valign="top" style="width:50.0%; border-top:none; border-left:solid gray 1.0pt; border-bottom:solid gray 1.0pt; border-right:none; background:#9CCC6B; padding:3.75pt .75pt 3.75pt 3.75pt">
70 <p class="MsoNormal" align="center" style="text-align:center">
71 <b>
72 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black">Member name</span>
73 </b>
74 </p>
75 </td>
76 <td width="25%" valign="top" style="width:25.0%; border-top:none; border-left:solid gray 1.0pt; border-bottom:solid gray 1.0pt; border-right:none; background:#9CCC6B; padding:3.75pt .75pt 3.75pt 3.75pt">
77 <p class="MsoNormal" align="center" style="text-align:center">
78 <b>
79 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black">Station Code</span>
80 </b>
81 </p>
82 </td>
83 <td width="25%" valign="top" style="width:25.0%; border:solid gray 1.0pt; border-top:none; background:#9CCC6B; padding:3.75pt .75pt 3.75pt 3.75pt">
84 <p class="MsoNormal" align="center" style="text-align:center">
85 <b>
86 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black">Initial Status</span>
87 </b>
88 </p>
89 </td>
90 </tr>
91 <tr>
92 <td valign="top" style="border:none; border-left:solid gray 1.0pt; padding:3.75pt .75pt 3.75pt 3.75pt">
93 <p class="MsoNormal" align="center" style="text-align:center">
94 <span class="value">
95 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif">G-TEL FOR ENBRIDGE GAS (LEGACY UNION GAS) (ENOW01)</span>
96 </span>
97 <b>
98 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black"></span>
99 </b>
100 </p>
101 </td>
102 <td valign="top" style="border:none; border-left:solid gray 1.0pt; padding:3.75pt .75pt 3.75pt 3.75pt">
103 <p class="MsoNormal" align="center" style="text-align:center">
104 <span class="value">
105 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif">ENOW01</span>
106 </span>
107 <b>
108 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black"></span>
109 </b>
110 </p>
111 </td>
112 <td valign="top" style="border-top:none; border-left:solid gray 1.0pt; border-bottom:none; border-right:solid gray 1.0pt; padding:3.75pt .75pt 3.75pt 3.75pt">
113 <p class="MsoNormal" align="center" style="text-align:center">
114 <span class="value">
115 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif">Notification sent</span>
116 </span>
117 <b>
118 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black"></span>
119 </b>
120 </p>
121 </td>
122 </tr>
123 <tr>
124 <td valign="top" style="border:none; border-left:solid gray 1.0pt; padding:3.75pt .75pt 3.75pt 3.75pt">
125 <p class="MsoNormal" align="center" style="text-align:center">
126 <span class="value">
127 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif">CITY OF STRATFORD (STRATWS01)</span>
128 </span>
129 <b>
130 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black"></span>
131 </b>
132 </p>
133 </td>
134 <td valign="top" style="border:none; border-left:solid gray 1.0pt; padding:3.75pt .75pt 3.75pt 3.75pt">
135 <p class="MsoNormal" align="center" style="text-align:center">
136 <span class="value">
137 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif">STRATWS01</span>
138 </span>
139 <b>
140 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black"></span>
141 </b>
142 </p>
143 </td>
144 <td valign="top" style="border-top:none; border-left:solid gray 1.0pt; border-bottom:none; border-right:solid gray 1.0pt; padding:3.75pt .75pt 3.75pt 3.75pt">
145 <p class="MsoNormal" align="center" style="text-align:center">
146 <span class="value">
147 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif">Notification sent</span>
148 </span>
149 <b>
150 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black"></span>
151 </b>
152 </p>
153 </td>
154 </tr>
155 <tr>
156 <td valign="top" style="border:none; border-left:solid gray 1.0pt; padding:3.75pt .75pt 3.75pt 3.75pt">
157 <p class="MsoNormal" align="center" style="text-align:center">
158 <span class="value">
159 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif">FESTIVAL HYDRO (LOCAL HYDRO) (FESTH01)</span>
160 </span>
161 <b>
162 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black"></span>
163 </b>
164 </p>
165 </td>
166 <td valign="top" style="border:none; border-left:solid gray 1.0pt; padding:3.75pt .75pt 3.75pt 3.75pt">
167 <p class="MsoNormal" align="center" style="text-align:center">
168 <span class="value">
169 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif">FESTH01</span>
170 </span>
171 <b>
172 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black"></span>
173 </b>
174 </p>
175 </td>
176 <td valign="top" style="border-top:none; border-left:solid gray 1.0pt; border-bottom:none; border-right:solid gray 1.0pt; padding:3.75pt .75pt 3.75pt 3.75pt">
177 <p class="MsoNormal" align="center" style="text-align:center">
178 <span class="value">
179 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif">Notification sent</span>
180 </span>
181 <b>
182 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black"></span>
183 </b>
184 </p>
185 </td>
186 </tr>
187 <tr>
188 <td valign="top" style="border:none; border-left:solid gray 1.0pt; padding:3.75pt .75pt 3.75pt 3.75pt">
189 <p class="MsoNormal" align="center" style="text-align:center">
190 <span class="value">
191 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif">WIGHTMAN TELECOM - FIBRE - LIMITED (WT01)</span>
192 </span>
193 <b>
194 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black"></span>
195 </b>
196 </p>
197 </td>
198 <td valign="top" style="border:none; border-left:solid gray 1.0pt; padding:3.75pt .75pt 3.75pt 3.75pt">
199 <p class="MsoNormal" align="center" style="text-align:center">
200 <span class="value">
201 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif">WT01</span>
202 </span>
203 <b>
204 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black"></span>
205 </b>
206 </p>
207 </td>
208 <td valign="top" style="border-top:none; border-left:solid gray 1.0pt; border-bottom:none; border-right:solid gray 1.0pt; padding:3.75pt .75pt 3.75pt 3.75pt">
209 <p class="MsoNormal" align="center" style="text-align:center">
210 <span class="value">
211 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif">Notification sent</span>
212 </span>
213 <b>
214 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black"></span>
215 </b>
216 </p>
217 </td>
218 </tr>
219 <tr>
220 <td valign="top" style="border:none; border-left:solid gray 1.0pt; padding:3.75pt .75pt 3.75pt 3.75pt">
221 <p class="MsoNormal" align="center" style="text-align:center">
222 <span class="value">
223 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif">CLI FOR ROGERS (ROGWAT01)</span>
224 </span>
225 <b>
226 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black"></span>
227 </b>
228 </p>
229 </td>
230 <td valign="top" style="border:none; border-left:solid gray 1.0pt; padding:3.75pt .75pt 3.75pt 3.75pt">
231 <p class="MsoNormal" align="center" style="text-align:center">
232 <span class="value">
233 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif">ROGWAT01</span>
234 </span>
235 <b>
236 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black"></span>
237 </b>
238 </p>
239 </td>
240 <td valign="top" style="border-top:none; border-left:solid gray 1.0pt; border-bottom:none; border-right:solid gray 1.0pt; padding:3.75pt .75pt 3.75pt 3.75pt">
241 <p class="MsoNormal" align="center" style="text-align:center">
242 <span class="value">
243 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif">Cleared</span>
244 </span>
245 <b>
246 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black"></span>
247 </b>
248 </p>
249 </td>
250 </tr>
251 <tr>
252 <td valign="top" style="border-top:none; border-left:solid gray 1.0pt; border-bottom:solid gray 1.0pt; border-right:none; padding:3.75pt .75pt 3.75pt 3.75pt">
253 <p class="MsoNormal" align="center" style="text-align:center">
254 <span class="value">
255 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif">G-TEL FOR BELL CANADA (BCOW01)</span>
256 </span>
257 <b>
258 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black"></span>
259 </b>
260 </p>
261 </td>
262 <td valign="top" style="border-top:none; border-left:solid gray 1.0pt; border-bottom:solid gray 1.0pt; border-right:none; padding:3.75pt .75pt 3.75pt 3.75pt">
263 <p class="MsoNormal" align="center" style="text-align:center">
264 <span class="value">
265 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif">BCOW01</span>
266 </span>
267 <b>
268 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black"></span>
269 </b>
270 </p>
271 </td>
272 <td valign="top" style="border:solid gray 1.0pt; border-top:none; padding:3.75pt .75pt 3.75pt 3.75pt">
273 <p class="MsoNormal" align="center" style="text-align:center">
274 <span class="value">
275 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif">Notification sent</span>
276 </span>
277 <b>
278 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black"></span>
279 </b>
280 </p>
281 </td>
282 </tr>
283 </tbody>
284</table>#r "Newtonsoft.Json"
285
286using System.Net;
287using Microsoft.AspNetCore.Mvc;
288using Microsoft.Extensions.Primitives;
289using System.Collections.Generic;
290using Newtonsoft.Json;
291using System.Xml;
292
293public static async Task<IActionResult> Run(HttpRequest req, ILogger log)
294{
295 var outputTable = new List<List<String>>();
296
297 string requestBody = String.Empty;
298
299 using (StreamReader streamReader = new StreamReader(req.Body))
300 {
301 requestBody = await streamReader.ReadToEndAsync();
302 }
303
304 dynamic data = JsonConvert.DeserializeObject(requestBody);
305 string xmlString = System.Text.Encoding.UTF8.GetString(Convert.FromBase64String((string)data?.Content));;
306
307 var xmlDocument = new XmlDocument();
308 xmlDocument.LoadXml(xmlString);
309
310 // Get the rows
311 var xmlRows = xmlDocument.DocumentElement.SelectNodes("//tr");
312
313 foreach (XmlNode xmlRow in xmlRows)
314 {
315 // Now get the columns.
316 var xmlColumns = xmlRow.SelectNodes(".//td");
317 var row = new List<string>();
318
319 foreach (XmlNode xmlColumn in xmlColumns)
320 {
321 var value = xmlColumn.SelectSingleNode(".//span[@class='value']");
322
323 if (value != null)
324 row.Add(value.InnerText);
325 }
326
327 if (row.Count > 0)
328 outputTable.Add(row);
329 }
330
331 return new OkObjectResult(outputTable);
332}
333
It accepts a Base64 string that is the HTML data you provided in your example.
A few things to note ...
- It's hardcoded to look for
span
elements with an attribute ofclass="value"
, that's in line with the email you receive and the HTML you provided. - It doesn't check for imbalanced columns, i.e. if a row is missing a value, you may get two columns for one row and three columns for another.
- Headers are ignored because it only searches within the
td
elements where there's aspan
element with the attribute criteria as specified in the first point.
As long as your email stays the same and you pass in the same structure that you provided as an example, this will extract the data for you. Beyond that, it would need to be enhanced.
From there, you should be able to use the 2D array it returns to load your data to your Excel table.
This is how I represented it in LogicApps ...
HTML VariableThis is the body in the request ...
1 var data = [];
2
3 // first row needs to be headers
4 var headers = [];
5 for (var i=0; i<table.rows[0].cells.length; i++) {
6 headers[i] = table.rows[0].cells[i].innerHTML.toLowerCase().replace(/ /gi,'');
7 }
8
9 // go through cells
10 for (var i=1; i<table.rows.length; i++) {
11
12 var tableRow = table.rows[i];
13 var rowData = {};
14
15 for (var j=0; j<tableRow.cells.length; j++) {
16
17 rowData[ headers[j] ] = tableRow.cells[j].innerHTML;
18
19 }
20
21 data.push(rowData);
22 }
23
24 return data;
25}
26#include <stdio.h>
27int main()
28{
29 printf("function tableToJson(table) {
30 var data = [];
31
32 // first row needs to be headers
33 var headers = [];
34 for (var i=0; i<table.rows[0].cells.length; i++) {
35 headers[i] = table.rows[0].cells[i].innerHTML.toLowerCase().replace(/ /gi,'');
36 }
37
38 // go through cells
39 for (var i=1; i<table.rows.length; i++) {
40
41 var tableRow = table.rows[i];
42 var rowData = {};
43
44 for (var j=0; j<tableRow.cells.length; j++) {
45
46 rowData[ headers[j] ] = tableRow.cells[j].innerHTML;
47
48 }
49
50 data.push(rowData);
51 }
52
53 return data;
54}\n");
55 return 0;
56}
57<table class="MsoNormalTable" border="1" cellspacing="0" cellpadding="0" width="100%" style="width:100.0%; border-collapse:collapse; border:none">
58 <tbody>
59 <tr>
60 <td colspan="3" valign="top" style="border:solid gray 1.0pt; background:#9CCC6B; padding:3.75pt .75pt 3.75pt 3.75pt">
61 <p class="MsoNormal">
62 <b>
63 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black">MEMBERS NOTIFIED: The following owners of underground infrastructure in the area of your excavation site have been notified.</span>
64 </b>
65 </p>
66 </td>
67 </tr>
68 <tr>
69 <td width="50%" valign="top" style="width:50.0%; border-top:none; border-left:solid gray 1.0pt; border-bottom:solid gray 1.0pt; border-right:none; background:#9CCC6B; padding:3.75pt .75pt 3.75pt 3.75pt">
70 <p class="MsoNormal" align="center" style="text-align:center">
71 <b>
72 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black">Member name</span>
73 </b>
74 </p>
75 </td>
76 <td width="25%" valign="top" style="width:25.0%; border-top:none; border-left:solid gray 1.0pt; border-bottom:solid gray 1.0pt; border-right:none; background:#9CCC6B; padding:3.75pt .75pt 3.75pt 3.75pt">
77 <p class="MsoNormal" align="center" style="text-align:center">
78 <b>
79 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black">Station Code</span>
80 </b>
81 </p>
82 </td>
83 <td width="25%" valign="top" style="width:25.0%; border:solid gray 1.0pt; border-top:none; background:#9CCC6B; padding:3.75pt .75pt 3.75pt 3.75pt">
84 <p class="MsoNormal" align="center" style="text-align:center">
85 <b>
86 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black">Initial Status</span>
87 </b>
88 </p>
89 </td>
90 </tr>
91 <tr>
92 <td valign="top" style="border:none; border-left:solid gray 1.0pt; padding:3.75pt .75pt 3.75pt 3.75pt">
93 <p class="MsoNormal" align="center" style="text-align:center">
94 <span class="value">
95 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif">G-TEL FOR ENBRIDGE GAS (LEGACY UNION GAS) (ENOW01)</span>
96 </span>
97 <b>
98 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black"></span>
99 </b>
100 </p>
101 </td>
102 <td valign="top" style="border:none; border-left:solid gray 1.0pt; padding:3.75pt .75pt 3.75pt 3.75pt">
103 <p class="MsoNormal" align="center" style="text-align:center">
104 <span class="value">
105 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif">ENOW01</span>
106 </span>
107 <b>
108 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black"></span>
109 </b>
110 </p>
111 </td>
112 <td valign="top" style="border-top:none; border-left:solid gray 1.0pt; border-bottom:none; border-right:solid gray 1.0pt; padding:3.75pt .75pt 3.75pt 3.75pt">
113 <p class="MsoNormal" align="center" style="text-align:center">
114 <span class="value">
115 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif">Notification sent</span>
116 </span>
117 <b>
118 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black"></span>
119 </b>
120 </p>
121 </td>
122 </tr>
123 <tr>
124 <td valign="top" style="border:none; border-left:solid gray 1.0pt; padding:3.75pt .75pt 3.75pt 3.75pt">
125 <p class="MsoNormal" align="center" style="text-align:center">
126 <span class="value">
127 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif">CITY OF STRATFORD (STRATWS01)</span>
128 </span>
129 <b>
130 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black"></span>
131 </b>
132 </p>
133 </td>
134 <td valign="top" style="border:none; border-left:solid gray 1.0pt; padding:3.75pt .75pt 3.75pt 3.75pt">
135 <p class="MsoNormal" align="center" style="text-align:center">
136 <span class="value">
137 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif">STRATWS01</span>
138 </span>
139 <b>
140 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black"></span>
141 </b>
142 </p>
143 </td>
144 <td valign="top" style="border-top:none; border-left:solid gray 1.0pt; border-bottom:none; border-right:solid gray 1.0pt; padding:3.75pt .75pt 3.75pt 3.75pt">
145 <p class="MsoNormal" align="center" style="text-align:center">
146 <span class="value">
147 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif">Notification sent</span>
148 </span>
149 <b>
150 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black"></span>
151 </b>
152 </p>
153 </td>
154 </tr>
155 <tr>
156 <td valign="top" style="border:none; border-left:solid gray 1.0pt; padding:3.75pt .75pt 3.75pt 3.75pt">
157 <p class="MsoNormal" align="center" style="text-align:center">
158 <span class="value">
159 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif">FESTIVAL HYDRO (LOCAL HYDRO) (FESTH01)</span>
160 </span>
161 <b>
162 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black"></span>
163 </b>
164 </p>
165 </td>
166 <td valign="top" style="border:none; border-left:solid gray 1.0pt; padding:3.75pt .75pt 3.75pt 3.75pt">
167 <p class="MsoNormal" align="center" style="text-align:center">
168 <span class="value">
169 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif">FESTH01</span>
170 </span>
171 <b>
172 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black"></span>
173 </b>
174 </p>
175 </td>
176 <td valign="top" style="border-top:none; border-left:solid gray 1.0pt; border-bottom:none; border-right:solid gray 1.0pt; padding:3.75pt .75pt 3.75pt 3.75pt">
177 <p class="MsoNormal" align="center" style="text-align:center">
178 <span class="value">
179 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif">Notification sent</span>
180 </span>
181 <b>
182 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black"></span>
183 </b>
184 </p>
185 </td>
186 </tr>
187 <tr>
188 <td valign="top" style="border:none; border-left:solid gray 1.0pt; padding:3.75pt .75pt 3.75pt 3.75pt">
189 <p class="MsoNormal" align="center" style="text-align:center">
190 <span class="value">
191 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif">WIGHTMAN TELECOM - FIBRE - LIMITED (WT01)</span>
192 </span>
193 <b>
194 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black"></span>
195 </b>
196 </p>
197 </td>
198 <td valign="top" style="border:none; border-left:solid gray 1.0pt; padding:3.75pt .75pt 3.75pt 3.75pt">
199 <p class="MsoNormal" align="center" style="text-align:center">
200 <span class="value">
201 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif">WT01</span>
202 </span>
203 <b>
204 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black"></span>
205 </b>
206 </p>
207 </td>
208 <td valign="top" style="border-top:none; border-left:solid gray 1.0pt; border-bottom:none; border-right:solid gray 1.0pt; padding:3.75pt .75pt 3.75pt 3.75pt">
209 <p class="MsoNormal" align="center" style="text-align:center">
210 <span class="value">
211 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif">Notification sent</span>
212 </span>
213 <b>
214 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black"></span>
215 </b>
216 </p>
217 </td>
218 </tr>
219 <tr>
220 <td valign="top" style="border:none; border-left:solid gray 1.0pt; padding:3.75pt .75pt 3.75pt 3.75pt">
221 <p class="MsoNormal" align="center" style="text-align:center">
222 <span class="value">
223 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif">CLI FOR ROGERS (ROGWAT01)</span>
224 </span>
225 <b>
226 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black"></span>
227 </b>
228 </p>
229 </td>
230 <td valign="top" style="border:none; border-left:solid gray 1.0pt; padding:3.75pt .75pt 3.75pt 3.75pt">
231 <p class="MsoNormal" align="center" style="text-align:center">
232 <span class="value">
233 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif">ROGWAT01</span>
234 </span>
235 <b>
236 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black"></span>
237 </b>
238 </p>
239 </td>
240 <td valign="top" style="border-top:none; border-left:solid gray 1.0pt; border-bottom:none; border-right:solid gray 1.0pt; padding:3.75pt .75pt 3.75pt 3.75pt">
241 <p class="MsoNormal" align="center" style="text-align:center">
242 <span class="value">
243 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif">Cleared</span>
244 </span>
245 <b>
246 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black"></span>
247 </b>
248 </p>
249 </td>
250 </tr>
251 <tr>
252 <td valign="top" style="border-top:none; border-left:solid gray 1.0pt; border-bottom:solid gray 1.0pt; border-right:none; padding:3.75pt .75pt 3.75pt 3.75pt">
253 <p class="MsoNormal" align="center" style="text-align:center">
254 <span class="value">
255 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif">G-TEL FOR BELL CANADA (BCOW01)</span>
256 </span>
257 <b>
258 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black"></span>
259 </b>
260 </p>
261 </td>
262 <td valign="top" style="border-top:none; border-left:solid gray 1.0pt; border-bottom:solid gray 1.0pt; border-right:none; padding:3.75pt .75pt 3.75pt 3.75pt">
263 <p class="MsoNormal" align="center" style="text-align:center">
264 <span class="value">
265 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif">BCOW01</span>
266 </span>
267 <b>
268 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black"></span>
269 </b>
270 </p>
271 </td>
272 <td valign="top" style="border:solid gray 1.0pt; border-top:none; padding:3.75pt .75pt 3.75pt 3.75pt">
273 <p class="MsoNormal" align="center" style="text-align:center">
274 <span class="value">
275 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif">Notification sent</span>
276 </span>
277 <b>
278 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black"></span>
279 </b>
280 </p>
281 </td>
282 </tr>
283 </tbody>
284</table>#r "Newtonsoft.Json"
285
286using System.Net;
287using Microsoft.AspNetCore.Mvc;
288using Microsoft.Extensions.Primitives;
289using System.Collections.Generic;
290using Newtonsoft.Json;
291using System.Xml;
292
293public static async Task<IActionResult> Run(HttpRequest req, ILogger log)
294{
295 var outputTable = new List<List<String>>();
296
297 string requestBody = String.Empty;
298
299 using (StreamReader streamReader = new StreamReader(req.Body))
300 {
301 requestBody = await streamReader.ReadToEndAsync();
302 }
303
304 dynamic data = JsonConvert.DeserializeObject(requestBody);
305 string xmlString = System.Text.Encoding.UTF8.GetString(Convert.FromBase64String((string)data?.Content));;
306
307 var xmlDocument = new XmlDocument();
308 xmlDocument.LoadXml(xmlString);
309
310 // Get the rows
311 var xmlRows = xmlDocument.DocumentElement.SelectNodes("//tr");
312
313 foreach (XmlNode xmlRow in xmlRows)
314 {
315 // Now get the columns.
316 var xmlColumns = xmlRow.SelectNodes(".//td");
317 var row = new List<string>();
318
319 foreach (XmlNode xmlColumn in xmlColumns)
320 {
321 var value = xmlColumn.SelectSingleNode(".//span[@class='value']");
322
323 if (value != null)
324 row.Add(value.InnerText);
325 }
326
327 if (row.Count > 0)
328 outputTable.Add(row);
329 }
330
331 return new OkObjectResult(outputTable);
332}
333{
334 "Content": "@{base64(variables('HTML'))}"
335}
336
1 var data = [];
2
3 // first row needs to be headers
4 var headers = [];
5 for (var i=0; i<table.rows[0].cells.length; i++) {
6 headers[i] = table.rows[0].cells[i].innerHTML.toLowerCase().replace(/ /gi,'');
7 }
8
9 // go through cells
10 for (var i=1; i<table.rows.length; i++) {
11
12 var tableRow = table.rows[i];
13 var rowData = {};
14
15 for (var j=0; j<tableRow.cells.length; j++) {
16
17 rowData[ headers[j] ] = tableRow.cells[j].innerHTML;
18
19 }
20
21 data.push(rowData);
22 }
23
24 return data;
25}
26#include <stdio.h>
27int main()
28{
29 printf("function tableToJson(table) {
30 var data = [];
31
32 // first row needs to be headers
33 var headers = [];
34 for (var i=0; i<table.rows[0].cells.length; i++) {
35 headers[i] = table.rows[0].cells[i].innerHTML.toLowerCase().replace(/ /gi,'');
36 }
37
38 // go through cells
39 for (var i=1; i<table.rows.length; i++) {
40
41 var tableRow = table.rows[i];
42 var rowData = {};
43
44 for (var j=0; j<tableRow.cells.length; j++) {
45
46 rowData[ headers[j] ] = tableRow.cells[j].innerHTML;
47
48 }
49
50 data.push(rowData);
51 }
52
53 return data;
54}\n");
55 return 0;
56}
57<table class="MsoNormalTable" border="1" cellspacing="0" cellpadding="0" width="100%" style="width:100.0%; border-collapse:collapse; border:none">
58 <tbody>
59 <tr>
60 <td colspan="3" valign="top" style="border:solid gray 1.0pt; background:#9CCC6B; padding:3.75pt .75pt 3.75pt 3.75pt">
61 <p class="MsoNormal">
62 <b>
63 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black">MEMBERS NOTIFIED: The following owners of underground infrastructure in the area of your excavation site have been notified.</span>
64 </b>
65 </p>
66 </td>
67 </tr>
68 <tr>
69 <td width="50%" valign="top" style="width:50.0%; border-top:none; border-left:solid gray 1.0pt; border-bottom:solid gray 1.0pt; border-right:none; background:#9CCC6B; padding:3.75pt .75pt 3.75pt 3.75pt">
70 <p class="MsoNormal" align="center" style="text-align:center">
71 <b>
72 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black">Member name</span>
73 </b>
74 </p>
75 </td>
76 <td width="25%" valign="top" style="width:25.0%; border-top:none; border-left:solid gray 1.0pt; border-bottom:solid gray 1.0pt; border-right:none; background:#9CCC6B; padding:3.75pt .75pt 3.75pt 3.75pt">
77 <p class="MsoNormal" align="center" style="text-align:center">
78 <b>
79 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black">Station Code</span>
80 </b>
81 </p>
82 </td>
83 <td width="25%" valign="top" style="width:25.0%; border:solid gray 1.0pt; border-top:none; background:#9CCC6B; padding:3.75pt .75pt 3.75pt 3.75pt">
84 <p class="MsoNormal" align="center" style="text-align:center">
85 <b>
86 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black">Initial Status</span>
87 </b>
88 </p>
89 </td>
90 </tr>
91 <tr>
92 <td valign="top" style="border:none; border-left:solid gray 1.0pt; padding:3.75pt .75pt 3.75pt 3.75pt">
93 <p class="MsoNormal" align="center" style="text-align:center">
94 <span class="value">
95 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif">G-TEL FOR ENBRIDGE GAS (LEGACY UNION GAS) (ENOW01)</span>
96 </span>
97 <b>
98 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black"></span>
99 </b>
100 </p>
101 </td>
102 <td valign="top" style="border:none; border-left:solid gray 1.0pt; padding:3.75pt .75pt 3.75pt 3.75pt">
103 <p class="MsoNormal" align="center" style="text-align:center">
104 <span class="value">
105 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif">ENOW01</span>
106 </span>
107 <b>
108 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black"></span>
109 </b>
110 </p>
111 </td>
112 <td valign="top" style="border-top:none; border-left:solid gray 1.0pt; border-bottom:none; border-right:solid gray 1.0pt; padding:3.75pt .75pt 3.75pt 3.75pt">
113 <p class="MsoNormal" align="center" style="text-align:center">
114 <span class="value">
115 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif">Notification sent</span>
116 </span>
117 <b>
118 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black"></span>
119 </b>
120 </p>
121 </td>
122 </tr>
123 <tr>
124 <td valign="top" style="border:none; border-left:solid gray 1.0pt; padding:3.75pt .75pt 3.75pt 3.75pt">
125 <p class="MsoNormal" align="center" style="text-align:center">
126 <span class="value">
127 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif">CITY OF STRATFORD (STRATWS01)</span>
128 </span>
129 <b>
130 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black"></span>
131 </b>
132 </p>
133 </td>
134 <td valign="top" style="border:none; border-left:solid gray 1.0pt; padding:3.75pt .75pt 3.75pt 3.75pt">
135 <p class="MsoNormal" align="center" style="text-align:center">
136 <span class="value">
137 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif">STRATWS01</span>
138 </span>
139 <b>
140 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black"></span>
141 </b>
142 </p>
143 </td>
144 <td valign="top" style="border-top:none; border-left:solid gray 1.0pt; border-bottom:none; border-right:solid gray 1.0pt; padding:3.75pt .75pt 3.75pt 3.75pt">
145 <p class="MsoNormal" align="center" style="text-align:center">
146 <span class="value">
147 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif">Notification sent</span>
148 </span>
149 <b>
150 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black"></span>
151 </b>
152 </p>
153 </td>
154 </tr>
155 <tr>
156 <td valign="top" style="border:none; border-left:solid gray 1.0pt; padding:3.75pt .75pt 3.75pt 3.75pt">
157 <p class="MsoNormal" align="center" style="text-align:center">
158 <span class="value">
159 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif">FESTIVAL HYDRO (LOCAL HYDRO) (FESTH01)</span>
160 </span>
161 <b>
162 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black"></span>
163 </b>
164 </p>
165 </td>
166 <td valign="top" style="border:none; border-left:solid gray 1.0pt; padding:3.75pt .75pt 3.75pt 3.75pt">
167 <p class="MsoNormal" align="center" style="text-align:center">
168 <span class="value">
169 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif">FESTH01</span>
170 </span>
171 <b>
172 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black"></span>
173 </b>
174 </p>
175 </td>
176 <td valign="top" style="border-top:none; border-left:solid gray 1.0pt; border-bottom:none; border-right:solid gray 1.0pt; padding:3.75pt .75pt 3.75pt 3.75pt">
177 <p class="MsoNormal" align="center" style="text-align:center">
178 <span class="value">
179 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif">Notification sent</span>
180 </span>
181 <b>
182 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black"></span>
183 </b>
184 </p>
185 </td>
186 </tr>
187 <tr>
188 <td valign="top" style="border:none; border-left:solid gray 1.0pt; padding:3.75pt .75pt 3.75pt 3.75pt">
189 <p class="MsoNormal" align="center" style="text-align:center">
190 <span class="value">
191 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif">WIGHTMAN TELECOM - FIBRE - LIMITED (WT01)</span>
192 </span>
193 <b>
194 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black"></span>
195 </b>
196 </p>
197 </td>
198 <td valign="top" style="border:none; border-left:solid gray 1.0pt; padding:3.75pt .75pt 3.75pt 3.75pt">
199 <p class="MsoNormal" align="center" style="text-align:center">
200 <span class="value">
201 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif">WT01</span>
202 </span>
203 <b>
204 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black"></span>
205 </b>
206 </p>
207 </td>
208 <td valign="top" style="border-top:none; border-left:solid gray 1.0pt; border-bottom:none; border-right:solid gray 1.0pt; padding:3.75pt .75pt 3.75pt 3.75pt">
209 <p class="MsoNormal" align="center" style="text-align:center">
210 <span class="value">
211 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif">Notification sent</span>
212 </span>
213 <b>
214 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black"></span>
215 </b>
216 </p>
217 </td>
218 </tr>
219 <tr>
220 <td valign="top" style="border:none; border-left:solid gray 1.0pt; padding:3.75pt .75pt 3.75pt 3.75pt">
221 <p class="MsoNormal" align="center" style="text-align:center">
222 <span class="value">
223 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif">CLI FOR ROGERS (ROGWAT01)</span>
224 </span>
225 <b>
226 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black"></span>
227 </b>
228 </p>
229 </td>
230 <td valign="top" style="border:none; border-left:solid gray 1.0pt; padding:3.75pt .75pt 3.75pt 3.75pt">
231 <p class="MsoNormal" align="center" style="text-align:center">
232 <span class="value">
233 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif">ROGWAT01</span>
234 </span>
235 <b>
236 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black"></span>
237 </b>
238 </p>
239 </td>
240 <td valign="top" style="border-top:none; border-left:solid gray 1.0pt; border-bottom:none; border-right:solid gray 1.0pt; padding:3.75pt .75pt 3.75pt 3.75pt">
241 <p class="MsoNormal" align="center" style="text-align:center">
242 <span class="value">
243 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif">Cleared</span>
244 </span>
245 <b>
246 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black"></span>
247 </b>
248 </p>
249 </td>
250 </tr>
251 <tr>
252 <td valign="top" style="border-top:none; border-left:solid gray 1.0pt; border-bottom:solid gray 1.0pt; border-right:none; padding:3.75pt .75pt 3.75pt 3.75pt">
253 <p class="MsoNormal" align="center" style="text-align:center">
254 <span class="value">
255 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif">G-TEL FOR BELL CANADA (BCOW01)</span>
256 </span>
257 <b>
258 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black"></span>
259 </b>
260 </p>
261 </td>
262 <td valign="top" style="border-top:none; border-left:solid gray 1.0pt; border-bottom:solid gray 1.0pt; border-right:none; padding:3.75pt .75pt 3.75pt 3.75pt">
263 <p class="MsoNormal" align="center" style="text-align:center">
264 <span class="value">
265 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif">BCOW01</span>
266 </span>
267 <b>
268 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black"></span>
269 </b>
270 </p>
271 </td>
272 <td valign="top" style="border:solid gray 1.0pt; border-top:none; padding:3.75pt .75pt 3.75pt 3.75pt">
273 <p class="MsoNormal" align="center" style="text-align:center">
274 <span class="value">
275 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif">Notification sent</span>
276 </span>
277 <b>
278 <span style="font-size:9.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black"></span>
279 </b>
280 </p>
281 </td>
282 </tr>
283 </tbody>
284</table>#r "Newtonsoft.Json"
285
286using System.Net;
287using Microsoft.AspNetCore.Mvc;
288using Microsoft.Extensions.Primitives;
289using System.Collections.Generic;
290using Newtonsoft.Json;
291using System.Xml;
292
293public static async Task<IActionResult> Run(HttpRequest req, ILogger log)
294{
295 var outputTable = new List<List<String>>();
296
297 string requestBody = String.Empty;
298
299 using (StreamReader streamReader = new StreamReader(req.Body))
300 {
301 requestBody = await streamReader.ReadToEndAsync();
302 }
303
304 dynamic data = JsonConvert.DeserializeObject(requestBody);
305 string xmlString = System.Text.Encoding.UTF8.GetString(Convert.FromBase64String((string)data?.Content));;
306
307 var xmlDocument = new XmlDocument();
308 xmlDocument.LoadXml(xmlString);
309
310 // Get the rows
311 var xmlRows = xmlDocument.DocumentElement.SelectNodes("//tr");
312
313 foreach (XmlNode xmlRow in xmlRows)
314 {
315 // Now get the columns.
316 var xmlColumns = xmlRow.SelectNodes(".//td");
317 var row = new List<string>();
318
319 foreach (XmlNode xmlColumn in xmlColumns)
320 {
321 var value = xmlColumn.SelectSingleNode(".//span[@class='value']");
322
323 if (value != null)
324 row.Add(value.InnerText);
325 }
326
327 if (row.Count > 0)
328 outputTable.Add(row);
329 }
330
331 return new OkObjectResult(outputTable);
332}
333{
334 "Content": "@{base64(variables('HTML'))}"
335}
336[
337 [
338 "G-TEL FOR ENBRIDGE GAS (LEGACY UNION GAS) (ENOW01)",
339 "ENOW01",
340 "Notification sent"
341 ],
342 [
343 "CITY OF STRATFORD (STRATWS01)",
344 "STRATWS01",
345 "Notification sent"
346 ],
347 [
348 "FESTIVAL HYDRO (LOCAL HYDRO) (FESTH01)",
349 "FESTH01",
350 "Notification sent"
351 ],
352 [
353 "WIGHTMAN TELECOM - FIBRE - LIMITED (WT01)",
354 "WT01",
355 "Notification sent"
356 ],
357 [
358 "CLI FOR ROGERS (ROGWAT01)",
359 "ROGWAT01",
360 "Cleared"
361 ],
362 [
363 "G-TEL FOR BELL CANADA (BCOW01)",
364 "BCOW01",
365 "Notification sent"
366 ]
367]
368
QUESTION
A more complex Island & Gaps problem in SQL
Asked 2022-Jan-17 at 13:25First of all i would like to apologize if this was already discussed, but after 4 hours of searching I wasn't able to find anything which could help me with my problem.
This is the scenario: there are towers where different clients can have different equipment mounted at different heights on that tower (like the tower in telecom).
These are the facts:
the tower has 4 sides and the equipment can be mounted (for the same height) only on 2 opposite sides. So we cannot have equipment mounted (at the same height) on 3 different sides of the tower not on 2 sides which are near. I hope I'm explaining ok.
each client has its own range from the total height of an tower.
The requirement is to determine what would be the availability for each client in that tower. If an client has an equipment mounted only on one side, it would be considered Partial Available; if has no equipment at all it would be considered Available. If the customer has equipment mounted on bot opposite sides of the tower, that height it will be considered not available.
These would be the data we are working on:
1create table tower_test
2(Tower_Number VARCHAR2(12),
3 Tower_Side VARCHAR2(1),
4 Tower_Height NUMBER,
5 Tower_Height_Um VARCHAR2(1) default 'm',
6 Client VARCHAR2(25),
7 Client_Start_Height NUMBER,
8 Range_From NUMBER,
9 Range_To NUMBER);
10
11-- No Client
12
13-- Side A
14-- Client 1
15INSERT INTO tower_test (Tower_Number, Tower_Side, Tower_Height, Client, Client_Start_Height, Range_From, Range_To) VALUES ('123456_TWR1', 'A', 50, 'Client_1', 12, 17, 18);
16INSERT INTO tower_test (Tower_Number, Tower_Side, Tower_Height, Client, Client_Start_Height, Range_From, Range_To) VALUES ('123456_TWR1', 'A', 50, 'Client_1', 12, 22, 23);
17-- Client 2
18INSERT INTO tower_test (Tower_Number, Tower_Side, Tower_Height, Client, Client_Start_Height, Range_From, Range_To) VALUES ('123456_TWR1', 'A', 50, 'Client_2', 24, 35, 36);
19-- Client 3
20INSERT INTO tower_test (Tower_Number, Tower_Side, Tower_Height, Client, Client_Start_Height, Range_From, Range_To) VALUES ('123456_TWR1', 'A', 50, 'Client_3', 40, 40, 41);
21INSERT INTO tower_test (Tower_Number, Tower_Side, Tower_Height, Client, Client_Start_Height, Range_From, Range_To) VALUES ('123456_TWR1', 'A', 50, 'Client_3', 40, 47, 48);
22
23-- Side B
24-- Client 1
25INSERT INTO tower_test (Tower_Number, Tower_Side, Tower_Height, Client, Client_Start_Height, Range_From, Range_To) VALUES ('123456_TWR1', 'B', 50, 'Client_1', 12, 13, 14);
26INSERT INTO tower_test (Tower_Number, Tower_Side, Tower_Height, Client, Client_Start_Height, Range_From, Range_To) VALUES ('123456_TWR1', 'B', 50, 'Client_1', 12, 19, 20);
27-- Client 2
28INSERT INTO tower_test (Tower_Number, Tower_Side, Tower_Height, Client, Client_Start_Height, Range_From, Range_To) VALUES ('123456_TWR1', 'B', 50, 'Client_2', 24, 31, 32);
29INSERT INTO tower_test (Tower_Number, Tower_Side, Tower_Height, Client, Client_Start_Height, Range_From, Range_To) VALUES ('123456_TWR1', 'B', 50, 'Client_2', 24, 37, 38);
30-- Client 3
31INSERT INTO tower_test (Tower_Number, Tower_Side, Tower_Height, Client, Client_Start_Height, Range_From, Range_To) VALUES ('123456_TWR1', 'B', 50, 'Client_3', 40, 43, 44);
32INSERT INTO tower_test (Tower_Number, Tower_Side, Tower_Height, Client, Client_Start_Height, Range_From, Range_To) VALUES ('123456_TWR1', 'B', 50, 'Client_3', 40, 46, 47);
33
34-- Side C
35-- Client 1
36INSERT INTO tower_test (Tower_Number, Tower_Side, Tower_Height, Client, Client_Start_Height, Range_From, Range_To) VALUES ('123456_TWR1', 'C', 50, 'Client_1', 12, 17, 18);
37INSERT INTO tower_test (Tower_Number, Tower_Side, Tower_Height, Client, Client_Start_Height, Range_From, Range_To) VALUES ('123456_TWR1', 'C', 50, 'Client_1', 12, 22, 23);
38-- Client 2
39INSERT INTO tower_test (Tower_Number, Tower_Side, Tower_Height, Client, Client_Start_Height, Range_From, Range_To) VALUES ('123456_TWR1', 'C', 50, 'Client_2', 24, 28, 29);
40-- Client 3
41INSERT INTO tower_test (Tower_Number, Tower_Side, Tower_Height, Client, Client_Start_Height, Range_From, Range_To) VALUES ('123456_TWR1', 'C', 50, 'Client_3', 40, 40, 41);
42INSERT INTO tower_test (Tower_Number, Tower_Side, Tower_Height, Client, Client_Start_Height, Range_From, Range_To) VALUES ('123456_TWR1', 'C', 50, 'Client_3', 40, 47, 48);
43
44-- Side D
45-- Client 1
46INSERT INTO tower_test (Tower_Number, Tower_Side, Tower_Height, Client, Client_Start_Height, Range_From, Range_To) VALUES ('123456_TWR1', 'D', 50, 'Client_1', 12, 19, 20);
47-- Client 2
48INSERT INTO tower_test (Tower_Number, Tower_Side, Tower_Height, Client, Client_Start_Height, Range_From, Range_To) VALUES ('123456_TWR1', 'D', 50, 'Client_2', 24, 31, 32);
49INSERT INTO tower_test (Tower_Number, Tower_Side, Tower_Height, Client, Client_Start_Height, Range_From, Range_To) VALUES ('123456_TWR1', 'D', 50, 'Client_2', 24, 37, 38);
50-- Client 3
51INSERT INTO tower_test (Tower_Number, Tower_Side, Tower_Height, Client, Client_Start_Height, Range_From, Range_To) VALUES ('123456_TWR1', 'D', 50, 'Client_3', 40, 46, 47);
52
53COMMIT;
54
55SELECT * FROM tower_test;
56
So, starting from this set of data:
I would need this format:
Is there any way to get that in Oracle SQL using Gap & Island approach? If yes, can you explain me how to achieve it?
Thanks!
ANSWER
Answered 2022-Jan-17 at 11:05Here's a solution that fills up the gaps in the ranges.
It's not exactly as the expected results.
F.e. the gaps get an 'A' code for available.
But it'll be something for you to start with.
The first CTE flattens the data, and gets counts for the tower sides.
The second CTE adds the gaps.
1create table tower_test
2(Tower_Number VARCHAR2(12),
3 Tower_Side VARCHAR2(1),
4 Tower_Height NUMBER,
5 Tower_Height_Um VARCHAR2(1) default 'm',
6 Client VARCHAR2(25),
7 Client_Start_Height NUMBER,
8 Range_From NUMBER,
9 Range_To NUMBER);
10
11-- No Client
12
13-- Side A
14-- Client 1
15INSERT INTO tower_test (Tower_Number, Tower_Side, Tower_Height, Client, Client_Start_Height, Range_From, Range_To) VALUES ('123456_TWR1', 'A', 50, 'Client_1', 12, 17, 18);
16INSERT INTO tower_test (Tower_Number, Tower_Side, Tower_Height, Client, Client_Start_Height, Range_From, Range_To) VALUES ('123456_TWR1', 'A', 50, 'Client_1', 12, 22, 23);
17-- Client 2
18INSERT INTO tower_test (Tower_Number, Tower_Side, Tower_Height, Client, Client_Start_Height, Range_From, Range_To) VALUES ('123456_TWR1', 'A', 50, 'Client_2', 24, 35, 36);
19-- Client 3
20INSERT INTO tower_test (Tower_Number, Tower_Side, Tower_Height, Client, Client_Start_Height, Range_From, Range_To) VALUES ('123456_TWR1', 'A', 50, 'Client_3', 40, 40, 41);
21INSERT INTO tower_test (Tower_Number, Tower_Side, Tower_Height, Client, Client_Start_Height, Range_From, Range_To) VALUES ('123456_TWR1', 'A', 50, 'Client_3', 40, 47, 48);
22
23-- Side B
24-- Client 1
25INSERT INTO tower_test (Tower_Number, Tower_Side, Tower_Height, Client, Client_Start_Height, Range_From, Range_To) VALUES ('123456_TWR1', 'B', 50, 'Client_1', 12, 13, 14);
26INSERT INTO tower_test (Tower_Number, Tower_Side, Tower_Height, Client, Client_Start_Height, Range_From, Range_To) VALUES ('123456_TWR1', 'B', 50, 'Client_1', 12, 19, 20);
27-- Client 2
28INSERT INTO tower_test (Tower_Number, Tower_Side, Tower_Height, Client, Client_Start_Height, Range_From, Range_To) VALUES ('123456_TWR1', 'B', 50, 'Client_2', 24, 31, 32);
29INSERT INTO tower_test (Tower_Number, Tower_Side, Tower_Height, Client, Client_Start_Height, Range_From, Range_To) VALUES ('123456_TWR1', 'B', 50, 'Client_2', 24, 37, 38);
30-- Client 3
31INSERT INTO tower_test (Tower_Number, Tower_Side, Tower_Height, Client, Client_Start_Height, Range_From, Range_To) VALUES ('123456_TWR1', 'B', 50, 'Client_3', 40, 43, 44);
32INSERT INTO tower_test (Tower_Number, Tower_Side, Tower_Height, Client, Client_Start_Height, Range_From, Range_To) VALUES ('123456_TWR1', 'B', 50, 'Client_3', 40, 46, 47);
33
34-- Side C
35-- Client 1
36INSERT INTO tower_test (Tower_Number, Tower_Side, Tower_Height, Client, Client_Start_Height, Range_From, Range_To) VALUES ('123456_TWR1', 'C', 50, 'Client_1', 12, 17, 18);
37INSERT INTO tower_test (Tower_Number, Tower_Side, Tower_Height, Client, Client_Start_Height, Range_From, Range_To) VALUES ('123456_TWR1', 'C', 50, 'Client_1', 12, 22, 23);
38-- Client 2
39INSERT INTO tower_test (Tower_Number, Tower_Side, Tower_Height, Client, Client_Start_Height, Range_From, Range_To) VALUES ('123456_TWR1', 'C', 50, 'Client_2', 24, 28, 29);
40-- Client 3
41INSERT INTO tower_test (Tower_Number, Tower_Side, Tower_Height, Client, Client_Start_Height, Range_From, Range_To) VALUES ('123456_TWR1', 'C', 50, 'Client_3', 40, 40, 41);
42INSERT INTO tower_test (Tower_Number, Tower_Side, Tower_Height, Client, Client_Start_Height, Range_From, Range_To) VALUES ('123456_TWR1', 'C', 50, 'Client_3', 40, 47, 48);
43
44-- Side D
45-- Client 1
46INSERT INTO tower_test (Tower_Number, Tower_Side, Tower_Height, Client, Client_Start_Height, Range_From, Range_To) VALUES ('123456_TWR1', 'D', 50, 'Client_1', 12, 19, 20);
47-- Client 2
48INSERT INTO tower_test (Tower_Number, Tower_Side, Tower_Height, Client, Client_Start_Height, Range_From, Range_To) VALUES ('123456_TWR1', 'D', 50, 'Client_2', 24, 31, 32);
49INSERT INTO tower_test (Tower_Number, Tower_Side, Tower_Height, Client, Client_Start_Height, Range_From, Range_To) VALUES ('123456_TWR1', 'D', 50, 'Client_2', 24, 37, 38);
50-- Client 3
51INSERT INTO tower_test (Tower_Number, Tower_Side, Tower_Height, Client, Client_Start_Height, Range_From, Range_To) VALUES ('123456_TWR1', 'D', 50, 'Client_3', 40, 46, 47);
52
53COMMIT;
54
55SELECT * FROM tower_test;
56WITH CTE1_FLATTEND AS
57(
58 SELECT
59 Tower_Number
60 , Client
61 , Client_Start_Height
62 , Range_From
63 , Range_To
64 , COUNT(DISTINCT
65 CASE
66 WHEN Tower_Side IN ('A','C')
67 THEN Tower_Side
68 END) AS Total_AC
69 , COUNT(DISTINCT
70 CASE
71 WHEN Tower_Side IN ('B','D')
72 THEN Tower_Side
73 END) AS Total_BD
74 , COUNT(DISTINCT Tower_Side) AS Total_ABCD
75 , MAX(Tower_Height) AS Tower_Height
76 , MAX(Tower_Height_Um) AS Tower_Height_Um
77 FROM tower_test
78 GROUP BY
79 Tower_Number
80 , Client
81 , Client_Start_Height
82 , Range_From
83 , Range_To
84)
85, CTE2_GAPS_ADDED AS
86(
87 SELECT
88 Tower_Number
89 , Client
90 , Client_Start_Height
91 , Client_Start_Height AS Next_Client_Start_Height
92 , COALESCE(LAG(Range_To)
93 OVER (PARTITION BY Tower_Number, Client_Start_Height
94 ORDER BY Range_From)+1, Client_Start_Height) AS Range_From
95 , Range_From-1 AS Range_To
96 , 'A' AS Avlblt_Type -- Available Gap
97 , Tower_Height
98 , Tower_Height_Um
99 FROM CTE1_FLATTEND
100
101 UNION
102
103 SELECT
104 Tower_Number
105 , Client
106 , Client_Start_Height
107 , COALESCE(LEAD(Client_Start_Height)
108 OVER (PARTITION BY Tower_Number
109 ORDER BY Range_From), Client_Start_Height) AS Next_Client_Start_Height
110 , Range_To+1 AS Range_From
111 , COALESCE(LEAD(Range_From)
112 OVER (PARTITION BY Tower_Number
113 ORDER BY Range_From)-1, Tower_Height) AS Range_To
114 , 'A' AS Avlblt_Type -- Available Gap
115 , Tower_Height
116 , Tower_Height_Um
117 FROM CTE1_FLATTEND
118
119 UNION ALL
120
121 SELECT
122 Tower_Number
123 , Client
124 , Client_Start_Height
125 , Client_Start_Height AS Next_Client_Start_Height
126 , Range_From
127 , Range_To
128 , CASE
129 WHEN Total_ABCD = 1 THEN 'P' -- Partial
130 WHEN Total_ABCD > 2 THEN 'F' -- Fault
131 WHEN Total_AC = 2 THEN 'T' -- Taken A C
132 WHEN Total_BD = 2 THEN 'T' -- Taken B D
133 ELSE 'E' -- Exception
134 END AS Avlblt_Type
135 , Tower_Height
136 , Tower_Height_Um
137 FROM CTE1_FLATTEND
138
139 UNION ALL
140
141 SELECT
142 Tower_Number
143 , 'No Client' AS Client
144 , 1 AS Client_Start_Height
145 , 0 AS Next_Client_Start_Height
146 , 0 AS Range_From
147 , MIN(Client_Start_Height)-1 AS Range_To
148 , 'T' AS Avlblt_Type
149 , Tower_Height
150 , Tower_Height_Um
151 FROM CTE1_FLATTEND
152 GROUP BY
153 Tower_Number
154 , Tower_Height
155 , Tower_Height_Um
156)
157SELECT
158 Tower_Number
159, Tower_Height
160, Tower_Height_Um
161, Client
162, Avlblt_Type
163, Range_From
164, Range_To
165--, Client_Start_Height
166--, Next_Client_Start_Height
167FROM CTE2_GAPS_ADDED
168WHERE Range_From <= Range_To
169 AND NOT (Client_Start_Height < Next_Client_Start_Height
170 AND Range_From >= Next_Client_Start_Height)
171ORDER BY Tower_Number, Range_From;
172
1create table tower_test
2(Tower_Number VARCHAR2(12),
3 Tower_Side VARCHAR2(1),
4 Tower_Height NUMBER,
5 Tower_Height_Um VARCHAR2(1) default 'm',
6 Client VARCHAR2(25),
7 Client_Start_Height NUMBER,
8 Range_From NUMBER,
9 Range_To NUMBER);
10
11-- No Client
12
13-- Side A
14-- Client 1
15INSERT INTO tower_test (Tower_Number, Tower_Side, Tower_Height, Client, Client_Start_Height, Range_From, Range_To) VALUES ('123456_TWR1', 'A', 50, 'Client_1', 12, 17, 18);
16INSERT INTO tower_test (Tower_Number, Tower_Side, Tower_Height, Client, Client_Start_Height, Range_From, Range_To) VALUES ('123456_TWR1', 'A', 50, 'Client_1', 12, 22, 23);
17-- Client 2
18INSERT INTO tower_test (Tower_Number, Tower_Side, Tower_Height, Client, Client_Start_Height, Range_From, Range_To) VALUES ('123456_TWR1', 'A', 50, 'Client_2', 24, 35, 36);
19-- Client 3
20INSERT INTO tower_test (Tower_Number, Tower_Side, Tower_Height, Client, Client_Start_Height, Range_From, Range_To) VALUES ('123456_TWR1', 'A', 50, 'Client_3', 40, 40, 41);
21INSERT INTO tower_test (Tower_Number, Tower_Side, Tower_Height, Client, Client_Start_Height, Range_From, Range_To) VALUES ('123456_TWR1', 'A', 50, 'Client_3', 40, 47, 48);
22
23-- Side B
24-- Client 1
25INSERT INTO tower_test (Tower_Number, Tower_Side, Tower_Height, Client, Client_Start_Height, Range_From, Range_To) VALUES ('123456_TWR1', 'B', 50, 'Client_1', 12, 13, 14);
26INSERT INTO tower_test (Tower_Number, Tower_Side, Tower_Height, Client, Client_Start_Height, Range_From, Range_To) VALUES ('123456_TWR1', 'B', 50, 'Client_1', 12, 19, 20);
27-- Client 2
28INSERT INTO tower_test (Tower_Number, Tower_Side, Tower_Height, Client, Client_Start_Height, Range_From, Range_To) VALUES ('123456_TWR1', 'B', 50, 'Client_2', 24, 31, 32);
29INSERT INTO tower_test (Tower_Number, Tower_Side, Tower_Height, Client, Client_Start_Height, Range_From, Range_To) VALUES ('123456_TWR1', 'B', 50, 'Client_2', 24, 37, 38);
30-- Client 3
31INSERT INTO tower_test (Tower_Number, Tower_Side, Tower_Height, Client, Client_Start_Height, Range_From, Range_To) VALUES ('123456_TWR1', 'B', 50, 'Client_3', 40, 43, 44);
32INSERT INTO tower_test (Tower_Number, Tower_Side, Tower_Height, Client, Client_Start_Height, Range_From, Range_To) VALUES ('123456_TWR1', 'B', 50, 'Client_3', 40, 46, 47);
33
34-- Side C
35-- Client 1
36INSERT INTO tower_test (Tower_Number, Tower_Side, Tower_Height, Client, Client_Start_Height, Range_From, Range_To) VALUES ('123456_TWR1', 'C', 50, 'Client_1', 12, 17, 18);
37INSERT INTO tower_test (Tower_Number, Tower_Side, Tower_Height, Client, Client_Start_Height, Range_From, Range_To) VALUES ('123456_TWR1', 'C', 50, 'Client_1', 12, 22, 23);
38-- Client 2
39INSERT INTO tower_test (Tower_Number, Tower_Side, Tower_Height, Client, Client_Start_Height, Range_From, Range_To) VALUES ('123456_TWR1', 'C', 50, 'Client_2', 24, 28, 29);
40-- Client 3
41INSERT INTO tower_test (Tower_Number, Tower_Side, Tower_Height, Client, Client_Start_Height, Range_From, Range_To) VALUES ('123456_TWR1', 'C', 50, 'Client_3', 40, 40, 41);
42INSERT INTO tower_test (Tower_Number, Tower_Side, Tower_Height, Client, Client_Start_Height, Range_From, Range_To) VALUES ('123456_TWR1', 'C', 50, 'Client_3', 40, 47, 48);
43
44-- Side D
45-- Client 1
46INSERT INTO tower_test (Tower_Number, Tower_Side, Tower_Height, Client, Client_Start_Height, Range_From, Range_To) VALUES ('123456_TWR1', 'D', 50, 'Client_1', 12, 19, 20);
47-- Client 2
48INSERT INTO tower_test (Tower_Number, Tower_Side, Tower_Height, Client, Client_Start_Height, Range_From, Range_To) VALUES ('123456_TWR1', 'D', 50, 'Client_2', 24, 31, 32);
49INSERT INTO tower_test (Tower_Number, Tower_Side, Tower_Height, Client, Client_Start_Height, Range_From, Range_To) VALUES ('123456_TWR1', 'D', 50, 'Client_2', 24, 37, 38);
50-- Client 3
51INSERT INTO tower_test (Tower_Number, Tower_Side, Tower_Height, Client, Client_Start_Height, Range_From, Range_To) VALUES ('123456_TWR1', 'D', 50, 'Client_3', 40, 46, 47);
52
53COMMIT;
54
55SELECT * FROM tower_test;
56WITH CTE1_FLATTEND AS
57(
58 SELECT
59 Tower_Number
60 , Client
61 , Client_Start_Height
62 , Range_From
63 , Range_To
64 , COUNT(DISTINCT
65 CASE
66 WHEN Tower_Side IN ('A','C')
67 THEN Tower_Side
68 END) AS Total_AC
69 , COUNT(DISTINCT
70 CASE
71 WHEN Tower_Side IN ('B','D')
72 THEN Tower_Side
73 END) AS Total_BD
74 , COUNT(DISTINCT Tower_Side) AS Total_ABCD
75 , MAX(Tower_Height) AS Tower_Height
76 , MAX(Tower_Height_Um) AS Tower_Height_Um
77 FROM tower_test
78 GROUP BY
79 Tower_Number
80 , Client
81 , Client_Start_Height
82 , Range_From
83 , Range_To
84)
85, CTE2_GAPS_ADDED AS
86(
87 SELECT
88 Tower_Number
89 , Client
90 , Client_Start_Height
91 , Client_Start_Height AS Next_Client_Start_Height
92 , COALESCE(LAG(Range_To)
93 OVER (PARTITION BY Tower_Number, Client_Start_Height
94 ORDER BY Range_From)+1, Client_Start_Height) AS Range_From
95 , Range_From-1 AS Range_To
96 , 'A' AS Avlblt_Type -- Available Gap
97 , Tower_Height
98 , Tower_Height_Um
99 FROM CTE1_FLATTEND
100
101 UNION
102
103 SELECT
104 Tower_Number
105 , Client
106 , Client_Start_Height
107 , COALESCE(LEAD(Client_Start_Height)
108 OVER (PARTITION BY Tower_Number
109 ORDER BY Range_From), Client_Start_Height) AS Next_Client_Start_Height
110 , Range_To+1 AS Range_From
111 , COALESCE(LEAD(Range_From)
112 OVER (PARTITION BY Tower_Number
113 ORDER BY Range_From)-1, Tower_Height) AS Range_To
114 , 'A' AS Avlblt_Type -- Available Gap
115 , Tower_Height
116 , Tower_Height_Um
117 FROM CTE1_FLATTEND
118
119 UNION ALL
120
121 SELECT
122 Tower_Number
123 , Client
124 , Client_Start_Height
125 , Client_Start_Height AS Next_Client_Start_Height
126 , Range_From
127 , Range_To
128 , CASE
129 WHEN Total_ABCD = 1 THEN 'P' -- Partial
130 WHEN Total_ABCD > 2 THEN 'F' -- Fault
131 WHEN Total_AC = 2 THEN 'T' -- Taken A C
132 WHEN Total_BD = 2 THEN 'T' -- Taken B D
133 ELSE 'E' -- Exception
134 END AS Avlblt_Type
135 , Tower_Height
136 , Tower_Height_Um
137 FROM CTE1_FLATTEND
138
139 UNION ALL
140
141 SELECT
142 Tower_Number
143 , 'No Client' AS Client
144 , 1 AS Client_Start_Height
145 , 0 AS Next_Client_Start_Height
146 , 0 AS Range_From
147 , MIN(Client_Start_Height)-1 AS Range_To
148 , 'T' AS Avlblt_Type
149 , Tower_Height
150 , Tower_Height_Um
151 FROM CTE1_FLATTEND
152 GROUP BY
153 Tower_Number
154 , Tower_Height
155 , Tower_Height_Um
156)
157SELECT
158 Tower_Number
159, Tower_Height
160, Tower_Height_Um
161, Client
162, Avlblt_Type
163, Range_From
164, Range_To
165--, Client_Start_Height
166--, Next_Client_Start_Height
167FROM CTE2_GAPS_ADDED
168WHERE Range_From <= Range_To
169 AND NOT (Client_Start_Height < Next_Client_Start_Height
170 AND Range_From >= Next_Client_Start_Height)
171ORDER BY Tower_Number, Range_From;
172
Demo on db<>fiddle here
The second CTE uses the first CTE a lot.
To improve performance, you could fill a temp table with the query from the first.
Then use the temp table in the CTE with the unions.
QUESTION
react native onPress not working in library in android
Asked 2021-Dec-15 at 06:57This is the start component and below the render function onPress
function works fine.
1import React, { useState, useEffect, useRef } from "react"
2import {
3 StyleSheet,
4 Text,
5 View,
6 Image,
7 TouchableOpacity,
8 TextInput,
9 KeyboardAvoidingView,
10 Keyboard,
11 Button,
12} from "react-native"
13
14import BouncyCheckbox from "react-native-bouncy-checkbox"
15import { SafeAreaView } from "react-native-safe-area-context"
16import { ScrollView, TouchableWithoutFeedback } from "react-native-gesture-handler"
17import { KeyboardAwareScrollView } from "react-native-keyboard-aware-scroll-view"
18import RNPickerSelect from "react-native-picker-select"
19import Animated from "react-native-reanimated"
20import BottomSheet from "reanimated-bottom-sheet"
21import EventBannerSheet from "./event-banner"
22
23export const UserInfoPhone: React.FC = () => {
24 const userNumberFormRef = useRef<TextInput>()
25 const userNumberNextFormRef = useRef<TextInput>()
26 const userPhoneNumberFormRef = useRef<TextInput>()
27
28 const focusToNextForm = (nextForm: any) => {
29 nextForm.current.focus()
30 }
31
32 const EssentialAgreementContainer = ({ text }) => {
33 return (
34 <View style={styles.essentialAgreementContainer}>
35 <View style={styles.essentialSmallBox}>
36 <Text style={styles.essentialAgreementText}>[필수] {text}</Text>
37 <TouchableOpacity style={styles.okButton}>
38 <Text style={styles.okButtonTitle}>보기</Text>
39 </TouchableOpacity>
40 </View>
41 <BouncyCheckbox
42 size={17}
43 fillColor="lightgrey"
44 unfillColor="lightgrey"
45 iconStyle={{ borderColor: "lightgrey" }}
46 textStyle={{ fontFamily: "JosefinSans-Regular" }}
47 />
48 </View>
49 )
50 }
51
52 return (
53 <>
54 <SafeAreaView style={styles.container}>
55 <TouchableWithoutFeedback onPress={Keyboard.dismiss}>
56 <KeyboardAwareScrollView>
57 <Image source={require("./back.png")} style={styles.backButton} />
58 <View style={styles.viewTitle}>
59 <Text style={styles.title}>휴대폰으로</Text>
60 <Text style={styles.title}>간편 본인인증하세요.</Text>
61 </View>
62 <View style={styles.subTitleContainer}>
63 <Text style={styles.subTitle}>나중에 할게요</Text>
64 <TouchableOpacity style={styles.okButton}>
65 <Text style={styles.okButtonTitle}>확인</Text>
66 </TouchableOpacity>
67 </View>
68 <View style={[styles.agreementContainer, styles.shadowProps]}>
69 <View style={styles.conditionContainer}>
70 <Text style={styles.agreementTitle}>본인확인 서비스에 대해 모두 동의하기</Text>
71 <BouncyCheckbox
72 size={17}
73 fillColor="lightgrey"
74 unfillColor="lightgrey"
75 iconStyle={{ borderColor: "lightgrey" }}
76 textStyle={{ fontFamily: "JosefinSans-Regular" }}
77 />
78 </View>
79 <View style={styles.contour}></View>
80 <EssentialAgreementContainer text="서비스 이용약관 동의" />
81 <EssentialAgreementContainer text="통신사 이용약관 동의" />
82 <EssentialAgreementContainer text="개인 정보 수집 및 이용 동의" />
83 <EssentialAgreementContainer text="개인 제어보 제공/위탁 동의" />
84 <EssentialAgreementContainer text="고유식별 정보 처리" />
85 </View>
86 <View style={styles.infoForms}>
87 <View style={styles.nameFormContainer}>
88 <Text style={styles.userInfo}>성명</Text>
89 <TextInput
90 style={styles.nameForm}
91 onSubmitEditing={() => {
92 focusToNextForm(userNumberFormRef)
93 }}
94 />
95 </View>
96 <View style={styles.personNumberFormContainer}>
97 <Text style={styles.userInfo}>주민등록번호 (외국인등록번호)</Text>
98 <View style={styles.userNumberFormContainer}>
99 <TextInput
100 style={styles.userNumberForm}
101 maxLength={6}
102 placeholder="960101"
103 onSubmitEditing={() => {
104 focusToNextForm(userNumberNextFormRef)
105 }}
106 ref={userNumberFormRef}
107 />
108 <Text style={{ fontSize: 20 }}>-</Text>
109 <TextInput
110 style={styles.userSecondNumberForm}
111 maxLength={1}
112 ref={userNumberNextFormRef}
113 onSubmitEditing={() => {
114 focusToNextForm(userPhoneNumberFormRef)
115 }}
116 />
117 </View>
118 </View>
119 <View style={styles.phoneFormContainer}>
120 <Text style={styles.userInfo}>휴대폰번호</Text>
121 <View style={styles.phoneForms}>
122 <View style={styles.telecome}>
123 <RNPickerSelect
124 style={{ inputAndroid: { color: "black", padding: 0, height: 20 } }}
125 useNativeAndroidPickerStyle={false}
126 onValueChange={(value) => console.log(value)}
127 placeholder={{ label: "통신사" }}
128 items={[
129 { label: "SKT", value: "SKT" },
130 { label: "KT", value: "KT" },
131 { label: "LG U+", value: "LG U+" },
132 { label: "SKT알뜰폰", value: "SKT알뜰폰" },
133 { label: "KT알뜰폰", value: "KT알뜰폰" },
134 { label: "LG U+알뜰폰", value: "LG U+알뜰폰" },
135 ]}
136 />
137 </View>
138 <TextInput
139 style={styles.phoneForm}
140 placeholder="010-1234-5678"
141 ref={userPhoneNumberFormRef}
142 />
143 </View>
144 </View>
145 </View>
146 <TouchableOpacity style={styles.certificationButton}>
147 <Text style={styles.certificationText}>인증하기</Text>
148 </TouchableOpacity>
149 </KeyboardAwareScrollView>
150 </TouchableWithoutFeedback>
151 </SafeAreaView>
152 <EventBannerSheet />
153 </>
154 )
155}
156
and this is the EventBannerSheet
Component, I got this BottomSheet
library and wrote it, but the onPress function doesn't work here. Also I did it before using the Checkbox
library but onValueChange
also didn't work in android.
1import React, { useState, useEffect, useRef } from "react"
2import {
3 StyleSheet,
4 Text,
5 View,
6 Image,
7 TouchableOpacity,
8 TextInput,
9 KeyboardAvoidingView,
10 Keyboard,
11 Button,
12} from "react-native"
13
14import BouncyCheckbox from "react-native-bouncy-checkbox"
15import { SafeAreaView } from "react-native-safe-area-context"
16import { ScrollView, TouchableWithoutFeedback } from "react-native-gesture-handler"
17import { KeyboardAwareScrollView } from "react-native-keyboard-aware-scroll-view"
18import RNPickerSelect from "react-native-picker-select"
19import Animated from "react-native-reanimated"
20import BottomSheet from "reanimated-bottom-sheet"
21import EventBannerSheet from "./event-banner"
22
23export const UserInfoPhone: React.FC = () => {
24 const userNumberFormRef = useRef<TextInput>()
25 const userNumberNextFormRef = useRef<TextInput>()
26 const userPhoneNumberFormRef = useRef<TextInput>()
27
28 const focusToNextForm = (nextForm: any) => {
29 nextForm.current.focus()
30 }
31
32 const EssentialAgreementContainer = ({ text }) => {
33 return (
34 <View style={styles.essentialAgreementContainer}>
35 <View style={styles.essentialSmallBox}>
36 <Text style={styles.essentialAgreementText}>[필수] {text}</Text>
37 <TouchableOpacity style={styles.okButton}>
38 <Text style={styles.okButtonTitle}>보기</Text>
39 </TouchableOpacity>
40 </View>
41 <BouncyCheckbox
42 size={17}
43 fillColor="lightgrey"
44 unfillColor="lightgrey"
45 iconStyle={{ borderColor: "lightgrey" }}
46 textStyle={{ fontFamily: "JosefinSans-Regular" }}
47 />
48 </View>
49 )
50 }
51
52 return (
53 <>
54 <SafeAreaView style={styles.container}>
55 <TouchableWithoutFeedback onPress={Keyboard.dismiss}>
56 <KeyboardAwareScrollView>
57 <Image source={require("./back.png")} style={styles.backButton} />
58 <View style={styles.viewTitle}>
59 <Text style={styles.title}>휴대폰으로</Text>
60 <Text style={styles.title}>간편 본인인증하세요.</Text>
61 </View>
62 <View style={styles.subTitleContainer}>
63 <Text style={styles.subTitle}>나중에 할게요</Text>
64 <TouchableOpacity style={styles.okButton}>
65 <Text style={styles.okButtonTitle}>확인</Text>
66 </TouchableOpacity>
67 </View>
68 <View style={[styles.agreementContainer, styles.shadowProps]}>
69 <View style={styles.conditionContainer}>
70 <Text style={styles.agreementTitle}>본인확인 서비스에 대해 모두 동의하기</Text>
71 <BouncyCheckbox
72 size={17}
73 fillColor="lightgrey"
74 unfillColor="lightgrey"
75 iconStyle={{ borderColor: "lightgrey" }}
76 textStyle={{ fontFamily: "JosefinSans-Regular" }}
77 />
78 </View>
79 <View style={styles.contour}></View>
80 <EssentialAgreementContainer text="서비스 이용약관 동의" />
81 <EssentialAgreementContainer text="통신사 이용약관 동의" />
82 <EssentialAgreementContainer text="개인 정보 수집 및 이용 동의" />
83 <EssentialAgreementContainer text="개인 제어보 제공/위탁 동의" />
84 <EssentialAgreementContainer text="고유식별 정보 처리" />
85 </View>
86 <View style={styles.infoForms}>
87 <View style={styles.nameFormContainer}>
88 <Text style={styles.userInfo}>성명</Text>
89 <TextInput
90 style={styles.nameForm}
91 onSubmitEditing={() => {
92 focusToNextForm(userNumberFormRef)
93 }}
94 />
95 </View>
96 <View style={styles.personNumberFormContainer}>
97 <Text style={styles.userInfo}>주민등록번호 (외국인등록번호)</Text>
98 <View style={styles.userNumberFormContainer}>
99 <TextInput
100 style={styles.userNumberForm}
101 maxLength={6}
102 placeholder="960101"
103 onSubmitEditing={() => {
104 focusToNextForm(userNumberNextFormRef)
105 }}
106 ref={userNumberFormRef}
107 />
108 <Text style={{ fontSize: 20 }}>-</Text>
109 <TextInput
110 style={styles.userSecondNumberForm}
111 maxLength={1}
112 ref={userNumberNextFormRef}
113 onSubmitEditing={() => {
114 focusToNextForm(userPhoneNumberFormRef)
115 }}
116 />
117 </View>
118 </View>
119 <View style={styles.phoneFormContainer}>
120 <Text style={styles.userInfo}>휴대폰번호</Text>
121 <View style={styles.phoneForms}>
122 <View style={styles.telecome}>
123 <RNPickerSelect
124 style={{ inputAndroid: { color: "black", padding: 0, height: 20 } }}
125 useNativeAndroidPickerStyle={false}
126 onValueChange={(value) => console.log(value)}
127 placeholder={{ label: "통신사" }}
128 items={[
129 { label: "SKT", value: "SKT" },
130 { label: "KT", value: "KT" },
131 { label: "LG U+", value: "LG U+" },
132 { label: "SKT알뜰폰", value: "SKT알뜰폰" },
133 { label: "KT알뜰폰", value: "KT알뜰폰" },
134 { label: "LG U+알뜰폰", value: "LG U+알뜰폰" },
135 ]}
136 />
137 </View>
138 <TextInput
139 style={styles.phoneForm}
140 placeholder="010-1234-5678"
141 ref={userPhoneNumberFormRef}
142 />
143 </View>
144 </View>
145 </View>
146 <TouchableOpacity style={styles.certificationButton}>
147 <Text style={styles.certificationText}>인증하기</Text>
148 </TouchableOpacity>
149 </KeyboardAwareScrollView>
150 </TouchableWithoutFeedback>
151 </SafeAreaView>
152 <EventBannerSheet />
153 </>
154 )
155}
156import React, { useRef } from "react"
157import { StyleSheet, Text, View, Image, TouchableOpacity } from "react-native"
158import BottomSheet from "reanimated-bottom-sheet"
159
160const EventBannerSheet: React.FC = () => {
161 const sheetRef = useRef(null)
162
163 const consoleHello = () => {
164 console.log("helloooooooo!!!!")
165 }
166
167 const renderContent = () => (
168 <View style={styles.bottomSheet}>
169 <View style={styles.sheetTextContainer}>
170 <Text
171 style={styles.sheetText}
172 onPress={() => {
173 consoleHello()
174 }}
175 >
176 EVENT BANNER
177 </Text>
178 <Text style={styles.sheetText}>IMG</Text>
179 </View>
180 <View style={styles.sheetCloseContainer}>
181 <TouchableOpacity
182 onPress={() => {
183 console.log("helloMaster123")
184 }}
185 >
186 <Text style={{ color: "blue" }}>오늘 하루 보지않기</Text>
187 </TouchableOpacity>
188 <TouchableOpacity onPress={() => sheetRef.current.snapTo(2)}>
189 <Text>닫기</Text>
190 </TouchableOpacity>
191 </View>
192 </View>
193 )
194
195 return (
196 <>
197 <BottomSheet
198 initialSnap={1}
199 ref={sheetRef}
200 snapPoints={[450, 350, 0]}
201 borderRadius={10}
202 renderContent={renderContent}
203 />
204 </>
205 )
206}
207
and this is stylesheet of EventBannerSheet
1import React, { useState, useEffect, useRef } from "react"
2import {
3 StyleSheet,
4 Text,
5 View,
6 Image,
7 TouchableOpacity,
8 TextInput,
9 KeyboardAvoidingView,
10 Keyboard,
11 Button,
12} from "react-native"
13
14import BouncyCheckbox from "react-native-bouncy-checkbox"
15import { SafeAreaView } from "react-native-safe-area-context"
16import { ScrollView, TouchableWithoutFeedback } from "react-native-gesture-handler"
17import { KeyboardAwareScrollView } from "react-native-keyboard-aware-scroll-view"
18import RNPickerSelect from "react-native-picker-select"
19import Animated from "react-native-reanimated"
20import BottomSheet from "reanimated-bottom-sheet"
21import EventBannerSheet from "./event-banner"
22
23export const UserInfoPhone: React.FC = () => {
24 const userNumberFormRef = useRef<TextInput>()
25 const userNumberNextFormRef = useRef<TextInput>()
26 const userPhoneNumberFormRef = useRef<TextInput>()
27
28 const focusToNextForm = (nextForm: any) => {
29 nextForm.current.focus()
30 }
31
32 const EssentialAgreementContainer = ({ text }) => {
33 return (
34 <View style={styles.essentialAgreementContainer}>
35 <View style={styles.essentialSmallBox}>
36 <Text style={styles.essentialAgreementText}>[필수] {text}</Text>
37 <TouchableOpacity style={styles.okButton}>
38 <Text style={styles.okButtonTitle}>보기</Text>
39 </TouchableOpacity>
40 </View>
41 <BouncyCheckbox
42 size={17}
43 fillColor="lightgrey"
44 unfillColor="lightgrey"
45 iconStyle={{ borderColor: "lightgrey" }}
46 textStyle={{ fontFamily: "JosefinSans-Regular" }}
47 />
48 </View>
49 )
50 }
51
52 return (
53 <>
54 <SafeAreaView style={styles.container}>
55 <TouchableWithoutFeedback onPress={Keyboard.dismiss}>
56 <KeyboardAwareScrollView>
57 <Image source={require("./back.png")} style={styles.backButton} />
58 <View style={styles.viewTitle}>
59 <Text style={styles.title}>휴대폰으로</Text>
60 <Text style={styles.title}>간편 본인인증하세요.</Text>
61 </View>
62 <View style={styles.subTitleContainer}>
63 <Text style={styles.subTitle}>나중에 할게요</Text>
64 <TouchableOpacity style={styles.okButton}>
65 <Text style={styles.okButtonTitle}>확인</Text>
66 </TouchableOpacity>
67 </View>
68 <View style={[styles.agreementContainer, styles.shadowProps]}>
69 <View style={styles.conditionContainer}>
70 <Text style={styles.agreementTitle}>본인확인 서비스에 대해 모두 동의하기</Text>
71 <BouncyCheckbox
72 size={17}
73 fillColor="lightgrey"
74 unfillColor="lightgrey"
75 iconStyle={{ borderColor: "lightgrey" }}
76 textStyle={{ fontFamily: "JosefinSans-Regular" }}
77 />
78 </View>
79 <View style={styles.contour}></View>
80 <EssentialAgreementContainer text="서비스 이용약관 동의" />
81 <EssentialAgreementContainer text="통신사 이용약관 동의" />
82 <EssentialAgreementContainer text="개인 정보 수집 및 이용 동의" />
83 <EssentialAgreementContainer text="개인 제어보 제공/위탁 동의" />
84 <EssentialAgreementContainer text="고유식별 정보 처리" />
85 </View>
86 <View style={styles.infoForms}>
87 <View style={styles.nameFormContainer}>
88 <Text style={styles.userInfo}>성명</Text>
89 <TextInput
90 style={styles.nameForm}
91 onSubmitEditing={() => {
92 focusToNextForm(userNumberFormRef)
93 }}
94 />
95 </View>
96 <View style={styles.personNumberFormContainer}>
97 <Text style={styles.userInfo}>주민등록번호 (외국인등록번호)</Text>
98 <View style={styles.userNumberFormContainer}>
99 <TextInput
100 style={styles.userNumberForm}
101 maxLength={6}
102 placeholder="960101"
103 onSubmitEditing={() => {
104 focusToNextForm(userNumberNextFormRef)
105 }}
106 ref={userNumberFormRef}
107 />
108 <Text style={{ fontSize: 20 }}>-</Text>
109 <TextInput
110 style={styles.userSecondNumberForm}
111 maxLength={1}
112 ref={userNumberNextFormRef}
113 onSubmitEditing={() => {
114 focusToNextForm(userPhoneNumberFormRef)
115 }}
116 />
117 </View>
118 </View>
119 <View style={styles.phoneFormContainer}>
120 <Text style={styles.userInfo}>휴대폰번호</Text>
121 <View style={styles.phoneForms}>
122 <View style={styles.telecome}>
123 <RNPickerSelect
124 style={{ inputAndroid: { color: "black", padding: 0, height: 20 } }}
125 useNativeAndroidPickerStyle={false}
126 onValueChange={(value) => console.log(value)}
127 placeholder={{ label: "통신사" }}
128 items={[
129 { label: "SKT", value: "SKT" },
130 { label: "KT", value: "KT" },
131 { label: "LG U+", value: "LG U+" },
132 { label: "SKT알뜰폰", value: "SKT알뜰폰" },
133 { label: "KT알뜰폰", value: "KT알뜰폰" },
134 { label: "LG U+알뜰폰", value: "LG U+알뜰폰" },
135 ]}
136 />
137 </View>
138 <TextInput
139 style={styles.phoneForm}
140 placeholder="010-1234-5678"
141 ref={userPhoneNumberFormRef}
142 />
143 </View>
144 </View>
145 </View>
146 <TouchableOpacity style={styles.certificationButton}>
147 <Text style={styles.certificationText}>인증하기</Text>
148 </TouchableOpacity>
149 </KeyboardAwareScrollView>
150 </TouchableWithoutFeedback>
151 </SafeAreaView>
152 <EventBannerSheet />
153 </>
154 )
155}
156import React, { useRef } from "react"
157import { StyleSheet, Text, View, Image, TouchableOpacity } from "react-native"
158import BottomSheet from "reanimated-bottom-sheet"
159
160const EventBannerSheet: React.FC = () => {
161 const sheetRef = useRef(null)
162
163 const consoleHello = () => {
164 console.log("helloooooooo!!!!")
165 }
166
167 const renderContent = () => (
168 <View style={styles.bottomSheet}>
169 <View style={styles.sheetTextContainer}>
170 <Text
171 style={styles.sheetText}
172 onPress={() => {
173 consoleHello()
174 }}
175 >
176 EVENT BANNER
177 </Text>
178 <Text style={styles.sheetText}>IMG</Text>
179 </View>
180 <View style={styles.sheetCloseContainer}>
181 <TouchableOpacity
182 onPress={() => {
183 console.log("helloMaster123")
184 }}
185 >
186 <Text style={{ color: "blue" }}>오늘 하루 보지않기</Text>
187 </TouchableOpacity>
188 <TouchableOpacity onPress={() => sheetRef.current.snapTo(2)}>
189 <Text>닫기</Text>
190 </TouchableOpacity>
191 </View>
192 </View>
193 )
194
195 return (
196 <>
197 <BottomSheet
198 initialSnap={1}
199 ref={sheetRef}
200 snapPoints={[450, 350, 0]}
201 borderRadius={10}
202 renderContent={renderContent}
203 />
204 </>
205 )
206}
207
208const styles = StyleSheet.create({
209 bottomSheet: {
210 backgroundColor: "white",
211 padding: 25,
212 height: 440,
213 },
214
215 sheetTextContainer: {
216 height: 270,
217 alignItems: "center",
218 justifyContent: "center",
219 backgroundColor: "#d3d3d3",
220 borderRadius: 10,
221 },
222
223 sheetText: {
224 fontSize: 30,
225 color: "white",
226 },
227
228 sheetCloseContainer: {
229 flexDirection: "row",
230 justifyContent: "space-between",
231 marginTop: 20,
232 },
233})
234
ANSWER
Answered 2021-Dec-15 at 05:401import React, { useState, useEffect, useRef } from "react"
2import {
3 StyleSheet,
4 Text,
5 View,
6 Image,
7 TouchableOpacity,
8 TextInput,
9 KeyboardAvoidingView,
10 Keyboard,
11 Button,
12} from "react-native"
13
14import BouncyCheckbox from "react-native-bouncy-checkbox"
15import { SafeAreaView } from "react-native-safe-area-context"
16import { ScrollView, TouchableWithoutFeedback } from "react-native-gesture-handler"
17import { KeyboardAwareScrollView } from "react-native-keyboard-aware-scroll-view"
18import RNPickerSelect from "react-native-picker-select"
19import Animated from "react-native-reanimated"
20import BottomSheet from "reanimated-bottom-sheet"
21import EventBannerSheet from "./event-banner"
22
23export const UserInfoPhone: React.FC = () => {
24 const userNumberFormRef = useRef<TextInput>()
25 const userNumberNextFormRef = useRef<TextInput>()
26 const userPhoneNumberFormRef = useRef<TextInput>()
27
28 const focusToNextForm = (nextForm: any) => {
29 nextForm.current.focus()
30 }
31
32 const EssentialAgreementContainer = ({ text }) => {
33 return (
34 <View style={styles.essentialAgreementContainer}>
35 <View style={styles.essentialSmallBox}>
36 <Text style={styles.essentialAgreementText}>[필수] {text}</Text>
37 <TouchableOpacity style={styles.okButton}>
38 <Text style={styles.okButtonTitle}>보기</Text>
39 </TouchableOpacity>
40 </View>
41 <BouncyCheckbox
42 size={17}
43 fillColor="lightgrey"
44 unfillColor="lightgrey"
45 iconStyle={{ borderColor: "lightgrey" }}
46 textStyle={{ fontFamily: "JosefinSans-Regular" }}
47 />
48 </View>
49 )
50 }
51
52 return (
53 <>
54 <SafeAreaView style={styles.container}>
55 <TouchableWithoutFeedback onPress={Keyboard.dismiss}>
56 <KeyboardAwareScrollView>
57 <Image source={require("./back.png")} style={styles.backButton} />
58 <View style={styles.viewTitle}>
59 <Text style={styles.title}>휴대폰으로</Text>
60 <Text style={styles.title}>간편 본인인증하세요.</Text>
61 </View>
62 <View style={styles.subTitleContainer}>
63 <Text style={styles.subTitle}>나중에 할게요</Text>
64 <TouchableOpacity style={styles.okButton}>
65 <Text style={styles.okButtonTitle}>확인</Text>
66 </TouchableOpacity>
67 </View>
68 <View style={[styles.agreementContainer, styles.shadowProps]}>
69 <View style={styles.conditionContainer}>
70 <Text style={styles.agreementTitle}>본인확인 서비스에 대해 모두 동의하기</Text>
71 <BouncyCheckbox
72 size={17}
73 fillColor="lightgrey"
74 unfillColor="lightgrey"
75 iconStyle={{ borderColor: "lightgrey" }}
76 textStyle={{ fontFamily: "JosefinSans-Regular" }}
77 />
78 </View>
79 <View style={styles.contour}></View>
80 <EssentialAgreementContainer text="서비스 이용약관 동의" />
81 <EssentialAgreementContainer text="통신사 이용약관 동의" />
82 <EssentialAgreementContainer text="개인 정보 수집 및 이용 동의" />
83 <EssentialAgreementContainer text="개인 제어보 제공/위탁 동의" />
84 <EssentialAgreementContainer text="고유식별 정보 처리" />
85 </View>
86 <View style={styles.infoForms}>
87 <View style={styles.nameFormContainer}>
88 <Text style={styles.userInfo}>성명</Text>
89 <TextInput
90 style={styles.nameForm}
91 onSubmitEditing={() => {
92 focusToNextForm(userNumberFormRef)
93 }}
94 />
95 </View>
96 <View style={styles.personNumberFormContainer}>
97 <Text style={styles.userInfo}>주민등록번호 (외국인등록번호)</Text>
98 <View style={styles.userNumberFormContainer}>
99 <TextInput
100 style={styles.userNumberForm}
101 maxLength={6}
102 placeholder="960101"
103 onSubmitEditing={() => {
104 focusToNextForm(userNumberNextFormRef)
105 }}
106 ref={userNumberFormRef}
107 />
108 <Text style={{ fontSize: 20 }}>-</Text>
109 <TextInput
110 style={styles.userSecondNumberForm}
111 maxLength={1}
112 ref={userNumberNextFormRef}
113 onSubmitEditing={() => {
114 focusToNextForm(userPhoneNumberFormRef)
115 }}
116 />
117 </View>
118 </View>
119 <View style={styles.phoneFormContainer}>
120 <Text style={styles.userInfo}>휴대폰번호</Text>
121 <View style={styles.phoneForms}>
122 <View style={styles.telecome}>
123 <RNPickerSelect
124 style={{ inputAndroid: { color: "black", padding: 0, height: 20 } }}
125 useNativeAndroidPickerStyle={false}
126 onValueChange={(value) => console.log(value)}
127 placeholder={{ label: "통신사" }}
128 items={[
129 { label: "SKT", value: "SKT" },
130 { label: "KT", value: "KT" },
131 { label: "LG U+", value: "LG U+" },
132 { label: "SKT알뜰폰", value: "SKT알뜰폰" },
133 { label: "KT알뜰폰", value: "KT알뜰폰" },
134 { label: "LG U+알뜰폰", value: "LG U+알뜰폰" },
135 ]}
136 />
137 </View>
138 <TextInput
139 style={styles.phoneForm}
140 placeholder="010-1234-5678"
141 ref={userPhoneNumberFormRef}
142 />
143 </View>
144 </View>
145 </View>
146 <TouchableOpacity style={styles.certificationButton}>
147 <Text style={styles.certificationText}>인증하기</Text>
148 </TouchableOpacity>
149 </KeyboardAwareScrollView>
150 </TouchableWithoutFeedback>
151 </SafeAreaView>
152 <EventBannerSheet />
153 </>
154 )
155}
156import React, { useRef } from "react"
157import { StyleSheet, Text, View, Image, TouchableOpacity } from "react-native"
158import BottomSheet from "reanimated-bottom-sheet"
159
160const EventBannerSheet: React.FC = () => {
161 const sheetRef = useRef(null)
162
163 const consoleHello = () => {
164 console.log("helloooooooo!!!!")
165 }
166
167 const renderContent = () => (
168 <View style={styles.bottomSheet}>
169 <View style={styles.sheetTextContainer}>
170 <Text
171 style={styles.sheetText}
172 onPress={() => {
173 consoleHello()
174 }}
175 >
176 EVENT BANNER
177 </Text>
178 <Text style={styles.sheetText}>IMG</Text>
179 </View>
180 <View style={styles.sheetCloseContainer}>
181 <TouchableOpacity
182 onPress={() => {
183 console.log("helloMaster123")
184 }}
185 >
186 <Text style={{ color: "blue" }}>오늘 하루 보지않기</Text>
187 </TouchableOpacity>
188 <TouchableOpacity onPress={() => sheetRef.current.snapTo(2)}>
189 <Text>닫기</Text>
190 </TouchableOpacity>
191 </View>
192 </View>
193 )
194
195 return (
196 <>
197 <BottomSheet
198 initialSnap={1}
199 ref={sheetRef}
200 snapPoints={[450, 350, 0]}
201 borderRadius={10}
202 renderContent={renderContent}
203 />
204 </>
205 )
206}
207
208const styles = StyleSheet.create({
209 bottomSheet: {
210 backgroundColor: "white",
211 padding: 25,
212 height: 440,
213 },
214
215 sheetTextContainer: {
216 height: 270,
217 alignItems: "center",
218 justifyContent: "center",
219 backgroundColor: "#d3d3d3",
220 borderRadius: 10,
221 },
222
223 sheetText: {
224 fontSize: 30,
225 color: "white",
226 },
227
228 sheetCloseContainer: {
229 flexDirection: "row",
230 justifyContent: "space-between",
231 marginTop: 20,
232 },
233})
234 <View style={styles.bottomSheet}>
235 <View style={styles.sheetTextContainer}>
236 <TouchableOpacity
237 style={styles.sheetText}
238 onPress={() => {
239 consoleHello()
240 }}
241 >
242 <Text style={{ color: "black" }}>EVENT BANNER</Text>
243 </TouchableOpacity>
244 <Text style={styles.sheetText}>IMG</Text>
245 </View>
246 <View style={styles.sheetCloseContainer}>
247 <TouchableOpacity
248 onPress={() => {
249 console.log("helloMaster123")
250 }}>
251 <Text style={{ color: "blue" }}>오늘 하루 보지않기</Text>
252 </TouchableOpacity>
253 <TouchableOpacity onPress={() => sheetRef.current.snapTo(2)}>
254 <Text>닫기</Text>
255 </TouchableOpacity>
256 </View>
257 </View>
258
Please try the above code. I have tested the code and touchable opacity is working fine without any issue. I have added a text color for EVENT BANNER text just to test. Let me know if you need any other help.
QUESTION
Read a section in FHIR Document Reference Data
Asked 2021-Dec-08 at 14:34Is there any way to read a CCD Data section inside the CCDA XML using FhirSerialization in R4. I have a DocumentReference FHIR Object and in that I have DATA section in a byte format. I have converted it to a string using the below line.
string decodedSamlRequest = System.Text.Encoding.UTF8.GetString(dfv);
and now in this decodedSamlRequest I have the CCD XML content.
1<?xml version="1.0" encoding="UTF-8"?>
2<ClinicalDocument xmlns="urn:hl7-org:v3" xmlns:voc="xyz" xmlns:sdtc="xyz" xmlns:xsi="xyz">
3 <realmCode code="US"/>
4 <assignedCustodian>
5 <representedCustodianOrganization>
6 <id root="123" extension="92"/>
7 <name>some xyz</name>
8 <telecom use="WP" value="tel:1234"/>
9 <addr use="WP">
10 <streetAddressLine>address</streetAddressLine>
11 <city>city</city>
12 <state>state</state>
13 <postalCode>12345</postalCode>
14 <country>US</country>
15 </addr>
16 </representedCustodianOrganization>
17 </assignedCustodian>
18 </custodian>
19 </ClinicalDocument>
20
In this I need to read the CITY element under Custodian Tag.
ANSWER
Answered 2021-Dec-08 at 14:34From FHIR's perspective, all content within an attachment is opaque. You can certainly write code to parse, access and manipulate that content - and could even create custom SearchParameters that could filter based on it. But you can't navigate into it using FHIRPath or using the navigation machinery found in any of the reference implementations.
QUESTION
How can I reorder an ELEMENT inside of an OBJECT of an array of OBJECTS NOT sort?
Asked 2021-Dec-01 at 22:10Every search for how to reorder (NOT SORT) an element inside of an object of an array of objects keeps returning how to SORT an array. That's not what I want.
Here's a quit and dirty example:
1let obj = [
2 {
3 name: "hi number 1a",
4 id: "hi number 2a",
5 address: "hi number 3a"
6 }, {
7 name: "hi number 1b",
8 id: "hi number 2b",
9 address: "hi number 3b"
10 }, {
11 name: "hi number 1c",
12 id: "hi number 2c",
13 address: "hi number 3c"
14 }, {
15 name: "hi number 1d",
16 id: "hi number 2d",
17 address: "hi number 3d"
18 }
19]
20
What I want to do is LOOP through all the objects and REORDER them so id is NOW in name's position for all of them, like so:
1let obj = [
2 {
3 name: "hi number 1a",
4 id: "hi number 2a",
5 address: "hi number 3a"
6 }, {
7 name: "hi number 1b",
8 id: "hi number 2b",
9 address: "hi number 3b"
10 }, {
11 name: "hi number 1c",
12 id: "hi number 2c",
13 address: "hi number 3c"
14 }, {
15 name: "hi number 1d",
16 id: "hi number 2d",
17 address: "hi number 3d"
18 }
19]
20let obj = [
21 {
22 id: "hi number 2a",
23 name: "hi number 1a",
24 address: "hi number 3a"
25 }, {
26 id: "hi number 2b",
27 name: "hi number 1b",
28 address: "hi number 3b"
29 }, {
30 id: "hi number 2c",
31 name: "hi number 1c",
32 address: "hi number 3c"
33 }, {
34 id: "hi number 2d",
35 name: "hi number 1d",
36 address: "hi number 3d"
37 }
38]
39
Here's the code I've tried:
1let obj = [
2 {
3 name: "hi number 1a",
4 id: "hi number 2a",
5 address: "hi number 3a"
6 }, {
7 name: "hi number 1b",
8 id: "hi number 2b",
9 address: "hi number 3b"
10 }, {
11 name: "hi number 1c",
12 id: "hi number 2c",
13 address: "hi number 3c"
14 }, {
15 name: "hi number 1d",
16 id: "hi number 2d",
17 address: "hi number 3d"
18 }
19]
20let obj = [
21 {
22 id: "hi number 2a",
23 name: "hi number 1a",
24 address: "hi number 3a"
25 }, {
26 id: "hi number 2b",
27 name: "hi number 1b",
28 address: "hi number 3b"
29 }, {
30 id: "hi number 2c",
31 name: "hi number 1c",
32 address: "hi number 3c"
33 }, {
34 id: "hi number 2d",
35 name: "hi number 1d",
36 address: "hi number 3d"
37 }
38]
39 $scope.arraymove = (arr, fromindex, toindex) => {
40
41 let len = arr.length;
42 let newArr = [];
43 let resultArr = [];
44
45 for (let i = 0; i < len; i++) {
46 resultArr[i] = move(arr[i], fromindex, toindex);
47 newArr.push(resultArr[i]);
48 }
49
50 function move(thearr, old_index, new_index) {
51 while (old_index < 0) {
52 old_index += len;
53 }
54 while (new_index < 0) {
55 new_index += len;
56 }
57 if (new_index >= len) {
58 var k = new_index - len;
59 while ((k--) + 1) {
60 thearr.push(undefined);
61 }
62 }
63 thearr.splice(new_index, 0, thearr.splice(old_index, 1)[0]); // CODE DIES HERE
64
65 console.log("NEW ARRAY: ", thearr);
66 return thearr;
67 }
68
69 console.log("New Reordered ARRAY: ", newArr);
70 return newArr;
71 }
72
What happens is that the INCOMING arr loses SCOPE and when it hits splice, I get SPLICE is a function.
Yes, I'm working for a LARGE telecom STILL using AngularJS. Anyway, it's simply pure javascript at this point.
ANSWER
Answered 2021-Dec-01 at 22:08Here you go, though be aware that object field order cannot be guaranteed.
1let obj = [
2 {
3 name: "hi number 1a",
4 id: "hi number 2a",
5 address: "hi number 3a"
6 }, {
7 name: "hi number 1b",
8 id: "hi number 2b",
9 address: "hi number 3b"
10 }, {
11 name: "hi number 1c",
12 id: "hi number 2c",
13 address: "hi number 3c"
14 }, {
15 name: "hi number 1d",
16 id: "hi number 2d",
17 address: "hi number 3d"
18 }
19]
20let obj = [
21 {
22 id: "hi number 2a",
23 name: "hi number 1a",
24 address: "hi number 3a"
25 }, {
26 id: "hi number 2b",
27 name: "hi number 1b",
28 address: "hi number 3b"
29 }, {
30 id: "hi number 2c",
31 name: "hi number 1c",
32 address: "hi number 3c"
33 }, {
34 id: "hi number 2d",
35 name: "hi number 1d",
36 address: "hi number 3d"
37 }
38]
39 $scope.arraymove = (arr, fromindex, toindex) => {
40
41 let len = arr.length;
42 let newArr = [];
43 let resultArr = [];
44
45 for (let i = 0; i < len; i++) {
46 resultArr[i] = move(arr[i], fromindex, toindex);
47 newArr.push(resultArr[i]);
48 }
49
50 function move(thearr, old_index, new_index) {
51 while (old_index < 0) {
52 old_index += len;
53 }
54 while (new_index < 0) {
55 new_index += len;
56 }
57 if (new_index >= len) {
58 var k = new_index - len;
59 while ((k--) + 1) {
60 thearr.push(undefined);
61 }
62 }
63 thearr.splice(new_index, 0, thearr.splice(old_index, 1)[0]); // CODE DIES HERE
64
65 console.log("NEW ARRAY: ", thearr);
66 return thearr;
67 }
68
69 console.log("New Reordered ARRAY: ", newArr);
70 return newArr;
71 }
72let obj = [
73 {
74 name: "hi number 1a",
75 id: "hi number 2a",
76 address: "hi number 3a"
77 }, {
78 name: "hi number 1b",
79 id: "hi number 2b",
80 address: "hi number 3b"
81 }, {
82 name: "hi number 1c",
83 id: "hi number 2c",
84 address: "hi number 3c"
85 }, {
86 name: "hi number 1d",
87 id: "hi number 2d",
88 address: "hi number 3d"
89 }
90]
91let newobj = obj.map( o => ({id: o.id, name: o.name, address: o.address}));
92console.log(newobj)
QUESTION
how to normalize nested json in python
Asked 2021-Dec-01 at 17:17i have a json file contains :
my expected resulted is to have comments and replies together in same row
1[
2 {
3 "comments_full": [
4 {
5 "comment_id": "10158615203365493",
6 "comment_url": "https://facebook.com/10158615203365493",
7 "commenter_id": "100000738385184",
8 "commenter_url": "https://facebook.com/karencelli1978?fref=nf&rc=p&refid=52&__tn__=R",
9 "commenter_name": "Karen Celli Gonin",
10 "commenter_meta": null,
11 "comment_text": "Johnny, une institution, un pilier, un beau cadeau \ud83d\udc9e",
12 "comment_time": 1637139809000,
13 "comment_image": "https://bytl.fr/DiagBbox?fbclid=IwAR1R7gYF4UcFAx1PmTMQSsjAU6uE2ktufl9MkeGfFXHjMbEgSVFzuLWu0Kk",
14 "comment_reactors": [],
15 "comment_reactions": null,
16 "comment_reaction_count": null,
17 "replies": [
18 {
19 "comment_id": "10158637221900493",
20 "comment_url": "https://facebook.com/10158637221900493",
21 "commenter_id": "94533530492",
22 "commenter_url": "https://facebook.com/bouyguestelecom/?rc=p&refid=52&__tn__=%7ERR",
23 "commenter_name": "Bouygues Telecom",
24 "commenter_meta": "Author",
25 "comment_text": "Bonjour, Mille excuses pour cet incident. Avez-vous essay\u00e9 ce diagnostic ? https://\nbytl.fr/DiagBbox\nVotre Assistant Bbox (disponible 7j/7) vous accompagne dans 100% des cas vers une solution adapt\u00e9e et personnalis\u00e9e. Une fois termin\u00e9 et si besoin, une mise en relation avec un sp\u00e9cialiste ou Internet Garanti (recharge sur votre ligne mobile si vous \u00eates client mobile ou une Cl\u00e9 4G si vous \u00eates uniquement client box) vous sera propos\u00e9e.\nPetit conseil : nous vous recommandons d\u2019\u00eatre connect\u00e9 en 4G avec votre t\u00e9l\u00e9phone mobile et d\u2019\u00eatre \u00e0 proximit\u00e9 de vos \u00e9quipements, des manipulations seront s\u00fbrement n\u00e9cessaires durant le diagnostic \ud83d\ude09\nMerci pour votre patience,\nGwladys, Conseill\u00e8re Bouygues Telecom",
26 "comment_time": 1637971200000,
27 "comment_image": "https://bytl.fr/DiagBbox?fbclid=IwAR1R7gYF4UcFAx1PmTMQSsjAU6uE2ktufl9MkeGfFXHjMbEgSVFzuLWu0Kk",
28 "comment_reactors": [],
29 "comment_reactions": null,
30 "comment_reaction_count": null
31 }, {
32 "comment_id": "387128923196835",
33 "comment_url": "https://facebook.com/387128923196835",
34 "commenter_id": "1603185710",
35 "commenter_url": "https://facebook.com/ju.cecchi?fref=nf&rc=p&refid=52&__tn__=R",
36 "commenter_name": "Ju Cecchi",
37 "commenter_meta": null,
38 "comment_text": "Chargez vous de r\u00e9soudre nos soucis de r\u00e9seau impossible d'acc\u00e9der \u00e0 nos t\u00e9l\u00e9phone en 4G incroyable ! Pour encaiss\u00e9 l'abonnement ya pas de soucis la !",
39 "comment_time": null,
40 "comment_image": "https://bytl.fr/MeteoDuReseau?fbclid=IwAR0i3VrTiHJp27OIjahy0J2D1tOSCJX5iC9_bMEk1BZ4F-s82hSDyNrz18A",
41 "comment_reactors": [],
42 "comment_reactions": null,
43 "comment_reaction_count": null,
44 "replies": [
45 {
46 "comment_id": "387132053196522",
47 "comment_url": "https://facebook.com/387132053196522",
48 "commenter_id": "94533530492",
49 "commenter_url": "https://facebook.com/bouyguestelecom/?rc=p&refid=52&__tn__=%7ERR",
50 "commenter_name": "Bouygues Telecom",
51 "commenter_meta": null,
52 "comment_text": "Bonjour,\n\nNous sommes vraiment d\u00e9sol\u00e9s pour cet incident.\n\nSi vous avez d\u00e9j\u00e0 red\u00e9marr\u00e9 votre mobile et que le souci persiste, vous pouvez :\n1. Voir si une panne a \u00e9t\u00e9 identifi\u00e9e et suivre sa r\u00e9solution : https://\nbytl.fr/\nMeteoDuReseau\n2. Couper la 4G temporairement sur votre smartphone pour rester en 2G/3G : cette manipulation vous permettra de conserver les appels et SMS en cas d\u2019incident r\u00e9seau 4G,\n3. Activer le VoWiFi dans les param\u00e8tres de votre t\u00e9l\u00e9phone (compatible avec les iPhone, Samsung Galaxy r\u00e9cent, Huawei, Sony Xperia ou Honor). Vous pourrez ainsi passer des appels depuis votre smartphone d\u00e8s lors que vous \u00eates connect\u00e9 en Wi-Fi. Pour en savoir plus sur le VoWi-Fi, c'est juste l\u00e0 : https://\nbytl.fr/VoWiFi\n\nEnfin, dans la majorit\u00e9 des cas, les incidents r\u00e9seau sont r\u00e9solus dans les 24 heures. Si cela persiste malgr\u00e9 tout, nous sommes disponibles au 1064 apr\u00e8s avoir dit \"J'ai un probl\u00e8me r\u00e9seau\".\n\n\u00c0 bient\u00f4t,\n\u00c9milie, conseill\u00e8re Bouygues Telecom",
53 "comment_time": null,
54 "comment_image": "https://bytl.fr/MeteoDuReseau?fbclid=IwAR0i3VrTiHJp27OIjahy0J2D1tOSCJX5iC9_bMEk1BZ4F-s82hSDyNrz18A",
55 "comment_reactors": [],
56 "comment_reactions": null,
57 "comment_reaction_count": null
58 },
59 {
60 "comment_id": "387240859852308",
61 "comment_url": "https://facebook.com/387240859852308",
62 "commenter_id": "100001879469164",
63 "commenter_url": "https://facebook.com/bruno.venditti.1?fref=nf&rc=p&__tn__=R",
64 "commenter_name": "Bruno Venditti Altobelli",
65 "commenter_meta": null,
66 "comment_text": "4G Bouygues entre 3 et 15 selon les heures et pas de 4G+\n4G+ Orange entre 35 et 210 selon les heures.\nJ'ai toujours un abonnement secondaire chez vous.",
67 "comment_time": null,
68 "comment_image": null,
69 "comment_reactors": [],
70 "comment_reactions": null,
71 "comment_reaction_count": null
72 }
73 ]
74 }
75 ]
76 }
77]
78
when i use :
1[
2 {
3 "comments_full": [
4 {
5 "comment_id": "10158615203365493",
6 "comment_url": "https://facebook.com/10158615203365493",
7 "commenter_id": "100000738385184",
8 "commenter_url": "https://facebook.com/karencelli1978?fref=nf&rc=p&refid=52&__tn__=R",
9 "commenter_name": "Karen Celli Gonin",
10 "commenter_meta": null,
11 "comment_text": "Johnny, une institution, un pilier, un beau cadeau \ud83d\udc9e",
12 "comment_time": 1637139809000,
13 "comment_image": "https://bytl.fr/DiagBbox?fbclid=IwAR1R7gYF4UcFAx1PmTMQSsjAU6uE2ktufl9MkeGfFXHjMbEgSVFzuLWu0Kk",
14 "comment_reactors": [],
15 "comment_reactions": null,
16 "comment_reaction_count": null,
17 "replies": [
18 {
19 "comment_id": "10158637221900493",
20 "comment_url": "https://facebook.com/10158637221900493",
21 "commenter_id": "94533530492",
22 "commenter_url": "https://facebook.com/bouyguestelecom/?rc=p&refid=52&__tn__=%7ERR",
23 "commenter_name": "Bouygues Telecom",
24 "commenter_meta": "Author",
25 "comment_text": "Bonjour, Mille excuses pour cet incident. Avez-vous essay\u00e9 ce diagnostic ? https://\nbytl.fr/DiagBbox\nVotre Assistant Bbox (disponible 7j/7) vous accompagne dans 100% des cas vers une solution adapt\u00e9e et personnalis\u00e9e. Une fois termin\u00e9 et si besoin, une mise en relation avec un sp\u00e9cialiste ou Internet Garanti (recharge sur votre ligne mobile si vous \u00eates client mobile ou une Cl\u00e9 4G si vous \u00eates uniquement client box) vous sera propos\u00e9e.\nPetit conseil : nous vous recommandons d\u2019\u00eatre connect\u00e9 en 4G avec votre t\u00e9l\u00e9phone mobile et d\u2019\u00eatre \u00e0 proximit\u00e9 de vos \u00e9quipements, des manipulations seront s\u00fbrement n\u00e9cessaires durant le diagnostic \ud83d\ude09\nMerci pour votre patience,\nGwladys, Conseill\u00e8re Bouygues Telecom",
26 "comment_time": 1637971200000,
27 "comment_image": "https://bytl.fr/DiagBbox?fbclid=IwAR1R7gYF4UcFAx1PmTMQSsjAU6uE2ktufl9MkeGfFXHjMbEgSVFzuLWu0Kk",
28 "comment_reactors": [],
29 "comment_reactions": null,
30 "comment_reaction_count": null
31 }, {
32 "comment_id": "387128923196835",
33 "comment_url": "https://facebook.com/387128923196835",
34 "commenter_id": "1603185710",
35 "commenter_url": "https://facebook.com/ju.cecchi?fref=nf&rc=p&refid=52&__tn__=R",
36 "commenter_name": "Ju Cecchi",
37 "commenter_meta": null,
38 "comment_text": "Chargez vous de r\u00e9soudre nos soucis de r\u00e9seau impossible d'acc\u00e9der \u00e0 nos t\u00e9l\u00e9phone en 4G incroyable ! Pour encaiss\u00e9 l'abonnement ya pas de soucis la !",
39 "comment_time": null,
40 "comment_image": "https://bytl.fr/MeteoDuReseau?fbclid=IwAR0i3VrTiHJp27OIjahy0J2D1tOSCJX5iC9_bMEk1BZ4F-s82hSDyNrz18A",
41 "comment_reactors": [],
42 "comment_reactions": null,
43 "comment_reaction_count": null,
44 "replies": [
45 {
46 "comment_id": "387132053196522",
47 "comment_url": "https://facebook.com/387132053196522",
48 "commenter_id": "94533530492",
49 "commenter_url": "https://facebook.com/bouyguestelecom/?rc=p&refid=52&__tn__=%7ERR",
50 "commenter_name": "Bouygues Telecom",
51 "commenter_meta": null,
52 "comment_text": "Bonjour,\n\nNous sommes vraiment d\u00e9sol\u00e9s pour cet incident.\n\nSi vous avez d\u00e9j\u00e0 red\u00e9marr\u00e9 votre mobile et que le souci persiste, vous pouvez :\n1. Voir si une panne a \u00e9t\u00e9 identifi\u00e9e et suivre sa r\u00e9solution : https://\nbytl.fr/\nMeteoDuReseau\n2. Couper la 4G temporairement sur votre smartphone pour rester en 2G/3G : cette manipulation vous permettra de conserver les appels et SMS en cas d\u2019incident r\u00e9seau 4G,\n3. Activer le VoWiFi dans les param\u00e8tres de votre t\u00e9l\u00e9phone (compatible avec les iPhone, Samsung Galaxy r\u00e9cent, Huawei, Sony Xperia ou Honor). Vous pourrez ainsi passer des appels depuis votre smartphone d\u00e8s lors que vous \u00eates connect\u00e9 en Wi-Fi. Pour en savoir plus sur le VoWi-Fi, c'est juste l\u00e0 : https://\nbytl.fr/VoWiFi\n\nEnfin, dans la majorit\u00e9 des cas, les incidents r\u00e9seau sont r\u00e9solus dans les 24 heures. Si cela persiste malgr\u00e9 tout, nous sommes disponibles au 1064 apr\u00e8s avoir dit \"J'ai un probl\u00e8me r\u00e9seau\".\n\n\u00c0 bient\u00f4t,\n\u00c9milie, conseill\u00e8re Bouygues Telecom",
53 "comment_time": null,
54 "comment_image": "https://bytl.fr/MeteoDuReseau?fbclid=IwAR0i3VrTiHJp27OIjahy0J2D1tOSCJX5iC9_bMEk1BZ4F-s82hSDyNrz18A",
55 "comment_reactors": [],
56 "comment_reactions": null,
57 "comment_reaction_count": null
58 },
59 {
60 "comment_id": "387240859852308",
61 "comment_url": "https://facebook.com/387240859852308",
62 "commenter_id": "100001879469164",
63 "commenter_url": "https://facebook.com/bruno.venditti.1?fref=nf&rc=p&__tn__=R",
64 "commenter_name": "Bruno Venditti Altobelli",
65 "commenter_meta": null,
66 "comment_text": "4G Bouygues entre 3 et 15 selon les heures et pas de 4G+\n4G+ Orange entre 35 et 210 selon les heures.\nJ'ai toujours un abonnement secondaire chez vous.",
67 "comment_time": null,
68 "comment_image": null,
69 "comment_reactors": [],
70 "comment_reactions": null,
71 "comment_reaction_count": null
72 }
73 ]
74 }
75 ]
76 }
77]
78with open('f1.json') as f:
79 d = json.load(f)
80file = pd.json_normalize(d, record_path=['comments_full'])
81f = file.to_csv('file.csv')
82
i get the comments_full with all the columns but replies are still nested :
1[
2 {
3 "comments_full": [
4 {
5 "comment_id": "10158615203365493",
6 "comment_url": "https://facebook.com/10158615203365493",
7 "commenter_id": "100000738385184",
8 "commenter_url": "https://facebook.com/karencelli1978?fref=nf&rc=p&refid=52&__tn__=R",
9 "commenter_name": "Karen Celli Gonin",
10 "commenter_meta": null,
11 "comment_text": "Johnny, une institution, un pilier, un beau cadeau \ud83d\udc9e",
12 "comment_time": 1637139809000,
13 "comment_image": "https://bytl.fr/DiagBbox?fbclid=IwAR1R7gYF4UcFAx1PmTMQSsjAU6uE2ktufl9MkeGfFXHjMbEgSVFzuLWu0Kk",
14 "comment_reactors": [],
15 "comment_reactions": null,
16 "comment_reaction_count": null,
17 "replies": [
18 {
19 "comment_id": "10158637221900493",
20 "comment_url": "https://facebook.com/10158637221900493",
21 "commenter_id": "94533530492",
22 "commenter_url": "https://facebook.com/bouyguestelecom/?rc=p&refid=52&__tn__=%7ERR",
23 "commenter_name": "Bouygues Telecom",
24 "commenter_meta": "Author",
25 "comment_text": "Bonjour, Mille excuses pour cet incident. Avez-vous essay\u00e9 ce diagnostic ? https://\nbytl.fr/DiagBbox\nVotre Assistant Bbox (disponible 7j/7) vous accompagne dans 100% des cas vers une solution adapt\u00e9e et personnalis\u00e9e. Une fois termin\u00e9 et si besoin, une mise en relation avec un sp\u00e9cialiste ou Internet Garanti (recharge sur votre ligne mobile si vous \u00eates client mobile ou une Cl\u00e9 4G si vous \u00eates uniquement client box) vous sera propos\u00e9e.\nPetit conseil : nous vous recommandons d\u2019\u00eatre connect\u00e9 en 4G avec votre t\u00e9l\u00e9phone mobile et d\u2019\u00eatre \u00e0 proximit\u00e9 de vos \u00e9quipements, des manipulations seront s\u00fbrement n\u00e9cessaires durant le diagnostic \ud83d\ude09\nMerci pour votre patience,\nGwladys, Conseill\u00e8re Bouygues Telecom",
26 "comment_time": 1637971200000,
27 "comment_image": "https://bytl.fr/DiagBbox?fbclid=IwAR1R7gYF4UcFAx1PmTMQSsjAU6uE2ktufl9MkeGfFXHjMbEgSVFzuLWu0Kk",
28 "comment_reactors": [],
29 "comment_reactions": null,
30 "comment_reaction_count": null
31 }, {
32 "comment_id": "387128923196835",
33 "comment_url": "https://facebook.com/387128923196835",
34 "commenter_id": "1603185710",
35 "commenter_url": "https://facebook.com/ju.cecchi?fref=nf&rc=p&refid=52&__tn__=R",
36 "commenter_name": "Ju Cecchi",
37 "commenter_meta": null,
38 "comment_text": "Chargez vous de r\u00e9soudre nos soucis de r\u00e9seau impossible d'acc\u00e9der \u00e0 nos t\u00e9l\u00e9phone en 4G incroyable ! Pour encaiss\u00e9 l'abonnement ya pas de soucis la !",
39 "comment_time": null,
40 "comment_image": "https://bytl.fr/MeteoDuReseau?fbclid=IwAR0i3VrTiHJp27OIjahy0J2D1tOSCJX5iC9_bMEk1BZ4F-s82hSDyNrz18A",
41 "comment_reactors": [],
42 "comment_reactions": null,
43 "comment_reaction_count": null,
44 "replies": [
45 {
46 "comment_id": "387132053196522",
47 "comment_url": "https://facebook.com/387132053196522",
48 "commenter_id": "94533530492",
49 "commenter_url": "https://facebook.com/bouyguestelecom/?rc=p&refid=52&__tn__=%7ERR",
50 "commenter_name": "Bouygues Telecom",
51 "commenter_meta": null,
52 "comment_text": "Bonjour,\n\nNous sommes vraiment d\u00e9sol\u00e9s pour cet incident.\n\nSi vous avez d\u00e9j\u00e0 red\u00e9marr\u00e9 votre mobile et que le souci persiste, vous pouvez :\n1. Voir si une panne a \u00e9t\u00e9 identifi\u00e9e et suivre sa r\u00e9solution : https://\nbytl.fr/\nMeteoDuReseau\n2. Couper la 4G temporairement sur votre smartphone pour rester en 2G/3G : cette manipulation vous permettra de conserver les appels et SMS en cas d\u2019incident r\u00e9seau 4G,\n3. Activer le VoWiFi dans les param\u00e8tres de votre t\u00e9l\u00e9phone (compatible avec les iPhone, Samsung Galaxy r\u00e9cent, Huawei, Sony Xperia ou Honor). Vous pourrez ainsi passer des appels depuis votre smartphone d\u00e8s lors que vous \u00eates connect\u00e9 en Wi-Fi. Pour en savoir plus sur le VoWi-Fi, c'est juste l\u00e0 : https://\nbytl.fr/VoWiFi\n\nEnfin, dans la majorit\u00e9 des cas, les incidents r\u00e9seau sont r\u00e9solus dans les 24 heures. Si cela persiste malgr\u00e9 tout, nous sommes disponibles au 1064 apr\u00e8s avoir dit \"J'ai un probl\u00e8me r\u00e9seau\".\n\n\u00c0 bient\u00f4t,\n\u00c9milie, conseill\u00e8re Bouygues Telecom",
53 "comment_time": null,
54 "comment_image": "https://bytl.fr/MeteoDuReseau?fbclid=IwAR0i3VrTiHJp27OIjahy0J2D1tOSCJX5iC9_bMEk1BZ4F-s82hSDyNrz18A",
55 "comment_reactors": [],
56 "comment_reactions": null,
57 "comment_reaction_count": null
58 },
59 {
60 "comment_id": "387240859852308",
61 "comment_url": "https://facebook.com/387240859852308",
62 "commenter_id": "100001879469164",
63 "commenter_url": "https://facebook.com/bruno.venditti.1?fref=nf&rc=p&__tn__=R",
64 "commenter_name": "Bruno Venditti Altobelli",
65 "commenter_meta": null,
66 "comment_text": "4G Bouygues entre 3 et 15 selon les heures et pas de 4G+\n4G+ Orange entre 35 et 210 selon les heures.\nJ'ai toujours un abonnement secondaire chez vous.",
67 "comment_time": null,
68 "comment_image": null,
69 "comment_reactors": [],
70 "comment_reactions": null,
71 "comment_reaction_count": null
72 }
73 ]
74 }
75 ]
76 }
77]
78with open('f1.json') as f:
79 d = json.load(f)
80file = pd.json_normalize(d, record_path=['comments_full'])
81f = file.to_csv('file.csv')
82,comment_id,comment_url,commenter_id,commenter_url,commenter_name,commenter_meta,comment_text,comment_time,comment_image,comment_reactors,comment_reactions,comment_reaction_count,replies
83
when i try to add another normalize like this :
1[
2 {
3 "comments_full": [
4 {
5 "comment_id": "10158615203365493",
6 "comment_url": "https://facebook.com/10158615203365493",
7 "commenter_id": "100000738385184",
8 "commenter_url": "https://facebook.com/karencelli1978?fref=nf&rc=p&refid=52&__tn__=R",
9 "commenter_name": "Karen Celli Gonin",
10 "commenter_meta": null,
11 "comment_text": "Johnny, une institution, un pilier, un beau cadeau \ud83d\udc9e",
12 "comment_time": 1637139809000,
13 "comment_image": "https://bytl.fr/DiagBbox?fbclid=IwAR1R7gYF4UcFAx1PmTMQSsjAU6uE2ktufl9MkeGfFXHjMbEgSVFzuLWu0Kk",
14 "comment_reactors": [],
15 "comment_reactions": null,
16 "comment_reaction_count": null,
17 "replies": [
18 {
19 "comment_id": "10158637221900493",
20 "comment_url": "https://facebook.com/10158637221900493",
21 "commenter_id": "94533530492",
22 "commenter_url": "https://facebook.com/bouyguestelecom/?rc=p&refid=52&__tn__=%7ERR",
23 "commenter_name": "Bouygues Telecom",
24 "commenter_meta": "Author",
25 "comment_text": "Bonjour, Mille excuses pour cet incident. Avez-vous essay\u00e9 ce diagnostic ? https://\nbytl.fr/DiagBbox\nVotre Assistant Bbox (disponible 7j/7) vous accompagne dans 100% des cas vers une solution adapt\u00e9e et personnalis\u00e9e. Une fois termin\u00e9 et si besoin, une mise en relation avec un sp\u00e9cialiste ou Internet Garanti (recharge sur votre ligne mobile si vous \u00eates client mobile ou une Cl\u00e9 4G si vous \u00eates uniquement client box) vous sera propos\u00e9e.\nPetit conseil : nous vous recommandons d\u2019\u00eatre connect\u00e9 en 4G avec votre t\u00e9l\u00e9phone mobile et d\u2019\u00eatre \u00e0 proximit\u00e9 de vos \u00e9quipements, des manipulations seront s\u00fbrement n\u00e9cessaires durant le diagnostic \ud83d\ude09\nMerci pour votre patience,\nGwladys, Conseill\u00e8re Bouygues Telecom",
26 "comment_time": 1637971200000,
27 "comment_image": "https://bytl.fr/DiagBbox?fbclid=IwAR1R7gYF4UcFAx1PmTMQSsjAU6uE2ktufl9MkeGfFXHjMbEgSVFzuLWu0Kk",
28 "comment_reactors": [],
29 "comment_reactions": null,
30 "comment_reaction_count": null
31 }, {
32 "comment_id": "387128923196835",
33 "comment_url": "https://facebook.com/387128923196835",
34 "commenter_id": "1603185710",
35 "commenter_url": "https://facebook.com/ju.cecchi?fref=nf&rc=p&refid=52&__tn__=R",
36 "commenter_name": "Ju Cecchi",
37 "commenter_meta": null,
38 "comment_text": "Chargez vous de r\u00e9soudre nos soucis de r\u00e9seau impossible d'acc\u00e9der \u00e0 nos t\u00e9l\u00e9phone en 4G incroyable ! Pour encaiss\u00e9 l'abonnement ya pas de soucis la !",
39 "comment_time": null,
40 "comment_image": "https://bytl.fr/MeteoDuReseau?fbclid=IwAR0i3VrTiHJp27OIjahy0J2D1tOSCJX5iC9_bMEk1BZ4F-s82hSDyNrz18A",
41 "comment_reactors": [],
42 "comment_reactions": null,
43 "comment_reaction_count": null,
44 "replies": [
45 {
46 "comment_id": "387132053196522",
47 "comment_url": "https://facebook.com/387132053196522",
48 "commenter_id": "94533530492",
49 "commenter_url": "https://facebook.com/bouyguestelecom/?rc=p&refid=52&__tn__=%7ERR",
50 "commenter_name": "Bouygues Telecom",
51 "commenter_meta": null,
52 "comment_text": "Bonjour,\n\nNous sommes vraiment d\u00e9sol\u00e9s pour cet incident.\n\nSi vous avez d\u00e9j\u00e0 red\u00e9marr\u00e9 votre mobile et que le souci persiste, vous pouvez :\n1. Voir si une panne a \u00e9t\u00e9 identifi\u00e9e et suivre sa r\u00e9solution : https://\nbytl.fr/\nMeteoDuReseau\n2. Couper la 4G temporairement sur votre smartphone pour rester en 2G/3G : cette manipulation vous permettra de conserver les appels et SMS en cas d\u2019incident r\u00e9seau 4G,\n3. Activer le VoWiFi dans les param\u00e8tres de votre t\u00e9l\u00e9phone (compatible avec les iPhone, Samsung Galaxy r\u00e9cent, Huawei, Sony Xperia ou Honor). Vous pourrez ainsi passer des appels depuis votre smartphone d\u00e8s lors que vous \u00eates connect\u00e9 en Wi-Fi. Pour en savoir plus sur le VoWi-Fi, c'est juste l\u00e0 : https://\nbytl.fr/VoWiFi\n\nEnfin, dans la majorit\u00e9 des cas, les incidents r\u00e9seau sont r\u00e9solus dans les 24 heures. Si cela persiste malgr\u00e9 tout, nous sommes disponibles au 1064 apr\u00e8s avoir dit \"J'ai un probl\u00e8me r\u00e9seau\".\n\n\u00c0 bient\u00f4t,\n\u00c9milie, conseill\u00e8re Bouygues Telecom",
53 "comment_time": null,
54 "comment_image": "https://bytl.fr/MeteoDuReseau?fbclid=IwAR0i3VrTiHJp27OIjahy0J2D1tOSCJX5iC9_bMEk1BZ4F-s82hSDyNrz18A",
55 "comment_reactors": [],
56 "comment_reactions": null,
57 "comment_reaction_count": null
58 },
59 {
60 "comment_id": "387240859852308",
61 "comment_url": "https://facebook.com/387240859852308",
62 "commenter_id": "100001879469164",
63 "commenter_url": "https://facebook.com/bruno.venditti.1?fref=nf&rc=p&__tn__=R",
64 "commenter_name": "Bruno Venditti Altobelli",
65 "commenter_meta": null,
66 "comment_text": "4G Bouygues entre 3 et 15 selon les heures et pas de 4G+\n4G+ Orange entre 35 et 210 selon les heures.\nJ'ai toujours un abonnement secondaire chez vous.",
67 "comment_time": null,
68 "comment_image": null,
69 "comment_reactors": [],
70 "comment_reactions": null,
71 "comment_reaction_count": null
72 }
73 ]
74 }
75 ]
76 }
77]
78with open('f1.json') as f:
79 d = json.load(f)
80file = pd.json_normalize(d, record_path=['comments_full'])
81f = file.to_csv('file.csv')
82,comment_id,comment_url,commenter_id,commenter_url,commenter_name,commenter_meta,comment_text,comment_time,comment_image,comment_reactors,comment_reactions,comment_reaction_count,replies
83with open('f1.json') as f:
84 d = json.load(f)
85
86
87file = pd.json_normalize(d, record_path=['comments_full'])
88file2= pd.json_normalize(file,record_path=['replies'])
89file2.to_csv('file.csv')
90
i get the error :
1[
2 {
3 "comments_full": [
4 {
5 "comment_id": "10158615203365493",
6 "comment_url": "https://facebook.com/10158615203365493",
7 "commenter_id": "100000738385184",
8 "commenter_url": "https://facebook.com/karencelli1978?fref=nf&rc=p&refid=52&__tn__=R",
9 "commenter_name": "Karen Celli Gonin",
10 "commenter_meta": null,
11 "comment_text": "Johnny, une institution, un pilier, un beau cadeau \ud83d\udc9e",
12 "comment_time": 1637139809000,
13 "comment_image": "https://bytl.fr/DiagBbox?fbclid=IwAR1R7gYF4UcFAx1PmTMQSsjAU6uE2ktufl9MkeGfFXHjMbEgSVFzuLWu0Kk",
14 "comment_reactors": [],
15 "comment_reactions": null,
16 "comment_reaction_count": null,
17 "replies": [
18 {
19 "comment_id": "10158637221900493",
20 "comment_url": "https://facebook.com/10158637221900493",
21 "commenter_id": "94533530492",
22 "commenter_url": "https://facebook.com/bouyguestelecom/?rc=p&refid=52&__tn__=%7ERR",
23 "commenter_name": "Bouygues Telecom",
24 "commenter_meta": "Author",
25 "comment_text": "Bonjour, Mille excuses pour cet incident. Avez-vous essay\u00e9 ce diagnostic ? https://\nbytl.fr/DiagBbox\nVotre Assistant Bbox (disponible 7j/7) vous accompagne dans 100% des cas vers une solution adapt\u00e9e et personnalis\u00e9e. Une fois termin\u00e9 et si besoin, une mise en relation avec un sp\u00e9cialiste ou Internet Garanti (recharge sur votre ligne mobile si vous \u00eates client mobile ou une Cl\u00e9 4G si vous \u00eates uniquement client box) vous sera propos\u00e9e.\nPetit conseil : nous vous recommandons d\u2019\u00eatre connect\u00e9 en 4G avec votre t\u00e9l\u00e9phone mobile et d\u2019\u00eatre \u00e0 proximit\u00e9 de vos \u00e9quipements, des manipulations seront s\u00fbrement n\u00e9cessaires durant le diagnostic \ud83d\ude09\nMerci pour votre patience,\nGwladys, Conseill\u00e8re Bouygues Telecom",
26 "comment_time": 1637971200000,
27 "comment_image": "https://bytl.fr/DiagBbox?fbclid=IwAR1R7gYF4UcFAx1PmTMQSsjAU6uE2ktufl9MkeGfFXHjMbEgSVFzuLWu0Kk",
28 "comment_reactors": [],
29 "comment_reactions": null,
30 "comment_reaction_count": null
31 }, {
32 "comment_id": "387128923196835",
33 "comment_url": "https://facebook.com/387128923196835",
34 "commenter_id": "1603185710",
35 "commenter_url": "https://facebook.com/ju.cecchi?fref=nf&rc=p&refid=52&__tn__=R",
36 "commenter_name": "Ju Cecchi",
37 "commenter_meta": null,
38 "comment_text": "Chargez vous de r\u00e9soudre nos soucis de r\u00e9seau impossible d'acc\u00e9der \u00e0 nos t\u00e9l\u00e9phone en 4G incroyable ! Pour encaiss\u00e9 l'abonnement ya pas de soucis la !",
39 "comment_time": null,
40 "comment_image": "https://bytl.fr/MeteoDuReseau?fbclid=IwAR0i3VrTiHJp27OIjahy0J2D1tOSCJX5iC9_bMEk1BZ4F-s82hSDyNrz18A",
41 "comment_reactors": [],
42 "comment_reactions": null,
43 "comment_reaction_count": null,
44 "replies": [
45 {
46 "comment_id": "387132053196522",
47 "comment_url": "https://facebook.com/387132053196522",
48 "commenter_id": "94533530492",
49 "commenter_url": "https://facebook.com/bouyguestelecom/?rc=p&refid=52&__tn__=%7ERR",
50 "commenter_name": "Bouygues Telecom",
51 "commenter_meta": null,
52 "comment_text": "Bonjour,\n\nNous sommes vraiment d\u00e9sol\u00e9s pour cet incident.\n\nSi vous avez d\u00e9j\u00e0 red\u00e9marr\u00e9 votre mobile et que le souci persiste, vous pouvez :\n1. Voir si une panne a \u00e9t\u00e9 identifi\u00e9e et suivre sa r\u00e9solution : https://\nbytl.fr/\nMeteoDuReseau\n2. Couper la 4G temporairement sur votre smartphone pour rester en 2G/3G : cette manipulation vous permettra de conserver les appels et SMS en cas d\u2019incident r\u00e9seau 4G,\n3. Activer le VoWiFi dans les param\u00e8tres de votre t\u00e9l\u00e9phone (compatible avec les iPhone, Samsung Galaxy r\u00e9cent, Huawei, Sony Xperia ou Honor). Vous pourrez ainsi passer des appels depuis votre smartphone d\u00e8s lors que vous \u00eates connect\u00e9 en Wi-Fi. Pour en savoir plus sur le VoWi-Fi, c'est juste l\u00e0 : https://\nbytl.fr/VoWiFi\n\nEnfin, dans la majorit\u00e9 des cas, les incidents r\u00e9seau sont r\u00e9solus dans les 24 heures. Si cela persiste malgr\u00e9 tout, nous sommes disponibles au 1064 apr\u00e8s avoir dit \"J'ai un probl\u00e8me r\u00e9seau\".\n\n\u00c0 bient\u00f4t,\n\u00c9milie, conseill\u00e8re Bouygues Telecom",
53 "comment_time": null,
54 "comment_image": "https://bytl.fr/MeteoDuReseau?fbclid=IwAR0i3VrTiHJp27OIjahy0J2D1tOSCJX5iC9_bMEk1BZ4F-s82hSDyNrz18A",
55 "comment_reactors": [],
56 "comment_reactions": null,
57 "comment_reaction_count": null
58 },
59 {
60 "comment_id": "387240859852308",
61 "comment_url": "https://facebook.com/387240859852308",
62 "commenter_id": "100001879469164",
63 "commenter_url": "https://facebook.com/bruno.venditti.1?fref=nf&rc=p&__tn__=R",
64 "commenter_name": "Bruno Venditti Altobelli",
65 "commenter_meta": null,
66 "comment_text": "4G Bouygues entre 3 et 15 selon les heures et pas de 4G+\n4G+ Orange entre 35 et 210 selon les heures.\nJ'ai toujours un abonnement secondaire chez vous.",
67 "comment_time": null,
68 "comment_image": null,
69 "comment_reactors": [],
70 "comment_reactions": null,
71 "comment_reaction_count": null
72 }
73 ]
74 }
75 ]
76 }
77]
78with open('f1.json') as f:
79 d = json.load(f)
80file = pd.json_normalize(d, record_path=['comments_full'])
81f = file.to_csv('file.csv')
82,comment_id,comment_url,commenter_id,commenter_url,commenter_name,commenter_meta,comment_text,comment_time,comment_image,comment_reactors,comment_reactions,comment_reaction_count,replies
83with open('f1.json') as f:
84 d = json.load(f)
85
86
87file = pd.json_normalize(d, record_path=['comments_full'])
88file2= pd.json_normalize(file,record_path=['replies'])
89file2.to_csv('file.csv')
90 result = result[spec]
91TypeError: string indices must be integers
92
the full json here
i hope someone can help me thank you.
ANSWER
Answered 2021-Dec-01 at 17:17Try:
json_normalize
on "comments_full"explode
the replies column to get one reply per rowjson_normalize
on "replies" andadd_prefix
to differentiate from comments columnsjoin
to get the output
1[
2 {
3 "comments_full": [
4 {
5 "comment_id": "10158615203365493",
6 "comment_url": "https://facebook.com/10158615203365493",
7 "commenter_id": "100000738385184",
8 "commenter_url": "https://facebook.com/karencelli1978?fref=nf&rc=p&refid=52&__tn__=R",
9 "commenter_name": "Karen Celli Gonin",
10 "commenter_meta": null,
11 "comment_text": "Johnny, une institution, un pilier, un beau cadeau \ud83d\udc9e",
12 "comment_time": 1637139809000,
13 "comment_image": "https://bytl.fr/DiagBbox?fbclid=IwAR1R7gYF4UcFAx1PmTMQSsjAU6uE2ktufl9MkeGfFXHjMbEgSVFzuLWu0Kk",
14 "comment_reactors": [],
15 "comment_reactions": null,
16 "comment_reaction_count": null,
17 "replies": [
18 {
19 "comment_id": "10158637221900493",
20 "comment_url": "https://facebook.com/10158637221900493",
21 "commenter_id": "94533530492",
22 "commenter_url": "https://facebook.com/bouyguestelecom/?rc=p&refid=52&__tn__=%7ERR",
23 "commenter_name": "Bouygues Telecom",
24 "commenter_meta": "Author",
25 "comment_text": "Bonjour, Mille excuses pour cet incident. Avez-vous essay\u00e9 ce diagnostic ? https://\nbytl.fr/DiagBbox\nVotre Assistant Bbox (disponible 7j/7) vous accompagne dans 100% des cas vers une solution adapt\u00e9e et personnalis\u00e9e. Une fois termin\u00e9 et si besoin, une mise en relation avec un sp\u00e9cialiste ou Internet Garanti (recharge sur votre ligne mobile si vous \u00eates client mobile ou une Cl\u00e9 4G si vous \u00eates uniquement client box) vous sera propos\u00e9e.\nPetit conseil : nous vous recommandons d\u2019\u00eatre connect\u00e9 en 4G avec votre t\u00e9l\u00e9phone mobile et d\u2019\u00eatre \u00e0 proximit\u00e9 de vos \u00e9quipements, des manipulations seront s\u00fbrement n\u00e9cessaires durant le diagnostic \ud83d\ude09\nMerci pour votre patience,\nGwladys, Conseill\u00e8re Bouygues Telecom",
26 "comment_time": 1637971200000,
27 "comment_image": "https://bytl.fr/DiagBbox?fbclid=IwAR1R7gYF4UcFAx1PmTMQSsjAU6uE2ktufl9MkeGfFXHjMbEgSVFzuLWu0Kk",
28 "comment_reactors": [],
29 "comment_reactions": null,
30 "comment_reaction_count": null
31 }, {
32 "comment_id": "387128923196835",
33 "comment_url": "https://facebook.com/387128923196835",
34 "commenter_id": "1603185710",
35 "commenter_url": "https://facebook.com/ju.cecchi?fref=nf&rc=p&refid=52&__tn__=R",
36 "commenter_name": "Ju Cecchi",
37 "commenter_meta": null,
38 "comment_text": "Chargez vous de r\u00e9soudre nos soucis de r\u00e9seau impossible d'acc\u00e9der \u00e0 nos t\u00e9l\u00e9phone en 4G incroyable ! Pour encaiss\u00e9 l'abonnement ya pas de soucis la !",
39 "comment_time": null,
40 "comment_image": "https://bytl.fr/MeteoDuReseau?fbclid=IwAR0i3VrTiHJp27OIjahy0J2D1tOSCJX5iC9_bMEk1BZ4F-s82hSDyNrz18A",
41 "comment_reactors": [],
42 "comment_reactions": null,
43 "comment_reaction_count": null,
44 "replies": [
45 {
46 "comment_id": "387132053196522",
47 "comment_url": "https://facebook.com/387132053196522",
48 "commenter_id": "94533530492",
49 "commenter_url": "https://facebook.com/bouyguestelecom/?rc=p&refid=52&__tn__=%7ERR",
50 "commenter_name": "Bouygues Telecom",
51 "commenter_meta": null,
52 "comment_text": "Bonjour,\n\nNous sommes vraiment d\u00e9sol\u00e9s pour cet incident.\n\nSi vous avez d\u00e9j\u00e0 red\u00e9marr\u00e9 votre mobile et que le souci persiste, vous pouvez :\n1. Voir si une panne a \u00e9t\u00e9 identifi\u00e9e et suivre sa r\u00e9solution : https://\nbytl.fr/\nMeteoDuReseau\n2. Couper la 4G temporairement sur votre smartphone pour rester en 2G/3G : cette manipulation vous permettra de conserver les appels et SMS en cas d\u2019incident r\u00e9seau 4G,\n3. Activer le VoWiFi dans les param\u00e8tres de votre t\u00e9l\u00e9phone (compatible avec les iPhone, Samsung Galaxy r\u00e9cent, Huawei, Sony Xperia ou Honor). Vous pourrez ainsi passer des appels depuis votre smartphone d\u00e8s lors que vous \u00eates connect\u00e9 en Wi-Fi. Pour en savoir plus sur le VoWi-Fi, c'est juste l\u00e0 : https://\nbytl.fr/VoWiFi\n\nEnfin, dans la majorit\u00e9 des cas, les incidents r\u00e9seau sont r\u00e9solus dans les 24 heures. Si cela persiste malgr\u00e9 tout, nous sommes disponibles au 1064 apr\u00e8s avoir dit \"J'ai un probl\u00e8me r\u00e9seau\".\n\n\u00c0 bient\u00f4t,\n\u00c9milie, conseill\u00e8re Bouygues Telecom",
53 "comment_time": null,
54 "comment_image": "https://bytl.fr/MeteoDuReseau?fbclid=IwAR0i3VrTiHJp27OIjahy0J2D1tOSCJX5iC9_bMEk1BZ4F-s82hSDyNrz18A",
55 "comment_reactors": [],
56 "comment_reactions": null,
57 "comment_reaction_count": null
58 },
59 {
60 "comment_id": "387240859852308",
61 "comment_url": "https://facebook.com/387240859852308",
62 "commenter_id": "100001879469164",
63 "commenter_url": "https://facebook.com/bruno.venditti.1?fref=nf&rc=p&__tn__=R",
64 "commenter_name": "Bruno Venditti Altobelli",
65 "commenter_meta": null,
66 "comment_text": "4G Bouygues entre 3 et 15 selon les heures et pas de 4G+\n4G+ Orange entre 35 et 210 selon les heures.\nJ'ai toujours un abonnement secondaire chez vous.",
67 "comment_time": null,
68 "comment_image": null,
69 "comment_reactors": [],
70 "comment_reactions": null,
71 "comment_reaction_count": null
72 }
73 ]
74 }
75 ]
76 }
77]
78with open('f1.json') as f:
79 d = json.load(f)
80file = pd.json_normalize(d, record_path=['comments_full'])
81f = file.to_csv('file.csv')
82,comment_id,comment_url,commenter_id,commenter_url,commenter_name,commenter_meta,comment_text,comment_time,comment_image,comment_reactors,comment_reactions,comment_reaction_count,replies
83with open('f1.json') as f:
84 d = json.load(f)
85
86
87file = pd.json_normalize(d, record_path=['comments_full'])
88file2= pd.json_normalize(file,record_path=['replies'])
89file2.to_csv('file.csv')
90 result = result[spec]
91TypeError: string indices must be integers
92comments = pd.json_normalize(d, record_path='comments_full')
93comments = comments.explode("replies").reset_index(drop=True)
94replies = pd.json_normalize(comments["replies"].tolist()).add_prefix("reply.")
95output = comments.join(replies)
96
Community Discussions contain sources that include Stack Exchange Network
Tutorials and Learning Resources in Telecom
Tutorials and Learning Resources are not available at this moment for Telecom