Explore all Telecom related open source software, libraries, packages, source code, cloud functions and APIs.

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

fastlane

by fastlane doticonrubydoticon

star image 34761 doticonMIT

🚀 The easiest way to automate building and releasing your iOS and Android apps

lottie-android

by airbnb doticonjavadoticon

star image 32616 doticonApache-2.0

Render After Effects animations natively on Android and iOS, Web, and React Native

Rocket.Chat

by RocketChat doticonjavascriptdoticon

star image 32191 doticonNOASSERTION

The communications platform that puts data protection first.

joplin

by laurent22 doticontypescriptdoticon

star image 29233 doticonNOASSERTION

Joplin - an open source note taking and to-do application with synchronization capabilities for Windows, macOS, Linux, Android and iOS.

algo

by trailofbits doticonpythondoticon

star image 24206 doticonAGPL-3.0

Set up a personal VPN in the cloud

Signal-Android

by signalapp doticonjavadoticon

star image 22277 doticonGPL-3.0

A private messenger for Android.

react-native-elements

by react-native-elements doticontypescriptdoticon

star image 22069 doticonMIT

Cross-Platform React Native UI Toolkit

eShopOnContainers

by dotnet-architecture doticoncsharpdoticon

star image 19919 doticonMIT

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.

NewPipe

by TeamNewPipe doticonjavadoticon

star image 18715 doticonGPL-3.0

A libre lightweight streaming front-end for Android.

Trending New libraries in Telecom

AarogyaSetu_Android

by nic-delhi doticonjavadoticon

star image 2830 doticonNOASSERTION

Aarogya Setu Android app native code

KOOM

by KwaiAppTeam doticonc++doticon

star image 2354 doticonNOASSERTION

KOOM is an OOM killer on mobile platform by Kwai.

OpenBot

by intel-isl doticonjavadoticon

star image 1827 doticonMIT

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.

instagrapi

by adw0rd doticonpythondoticon

star image 782 doticonMIT

🔥 The fastest and powerful Python library for Instagram Private API 2022

PCAPdroid

by emanuele-f doticoncdoticon

star image 484 doticonGPL-3.0

No-root network monitor and traffic dump tool for Android devices

bot

by GramAddict doticonpythondoticon

star image 300 doticonMIT

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.

WhatsApp-Clone

by yuvraj24 doticonjavascriptdoticon

star image 232 doticonMIT

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. 🔥🔥

react-native-phone-number-input

by garganurag893 doticonjavascriptdoticon

star image 208 doticonMIT

React Native component for phone number.

ROS-Mobile-Android

by ROS-Mobile doticonjavadoticon

star image 152 doticon

Visualization and controlling application for Android

Top Authors in Telecom

1

TwilioDevEd

24 Libraries

star icon210

2

philnash

10 Libraries

star icon146

3

twilio

8 Libraries

star icon1708

4

PacktPublishing

6 Libraries

star icon110

5

AYIDouble

6 Libraries

star icon47

6

kancart

4 Libraries

star icon33

7

RightMesh

4 Libraries

star icon23

8

thegenuinegourav

4 Libraries

star icon84

9

IBM

4 Libraries

star icon67

10

viniciusthiengo

4 Libraries

star icon47

1

24 Libraries

star icon210

2

10 Libraries

star icon146

3

8 Libraries

star icon1708

4

6 Libraries

star icon110

5

6 Libraries

star icon47

6

4 Libraries

star icon33

7

4 Libraries

star icon23

8

4 Libraries

star icon84

9

4 Libraries

star icon67

10

4 Libraries

star icon47

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:09

I 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:09

If 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

Source https://stackoverflow.com/questions/71528878

QUESTION

Python loop through ndjson file data

Asked 2022-Feb-22 at 12:04

I 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:04

See 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
EDIT

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

Source https://stackoverflow.com/questions/71220081

QUESTION

Incoming call notification - Android/iOS

Asked 2022-Jan-28 at 00:35

I 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.

enter image description here

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:35

I 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

Source https://stackoverflow.com/questions/70659383

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:29
Background

I'm working on an app that implements InCallService, so it can handle phone calls

The problem

On 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 found
  1. Given 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.

  2. 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).

  3. 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
  1. There was an old code that doesn't work anymore that uses call.getDetails().getAccountHandle().getId() and SubscriptionManager.from(context)getActiveSubscriptionInfoList().getActiveSubscriptionInfoList() .

  2. I think I can use telephonyManager.getSubscriptionId(callDetails.getAccountHandle()) , but it requires API 30, which is quite new...

The questions

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:29

Use 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

Source https://stackoverflow.com/questions/69809767

QUESTION

How do I convert an HTML table into JSON in Logic Apps

Asked 2022-Jan-24 at 12:27

I 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:"Arial",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:"Arial",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:"Arial",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:"Arial",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:"Arial",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:"Arial",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:"Arial",sans-serif">ENOW01</span>
106          </span>
107          <b>
108            <span style="font-size:9.0pt; font-family:"Arial",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:"Arial",sans-serif">Notification sent</span>
116          </span>
117          <b>
118            <span style="font-size:9.0pt; font-family:"Arial",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:"Arial",sans-serif">CITY OF STRATFORD (STRATWS01)</span>
128          </span>
129          <b>
130            <span style="font-size:9.0pt; font-family:"Arial",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:"Arial",sans-serif">STRATWS01</span>
138          </span>
139          <b>
140            <span style="font-size:9.0pt; font-family:"Arial",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:"Arial",sans-serif">Notification sent</span>
148          </span>
149          <b>
150            <span style="font-size:9.0pt; font-family:"Arial",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:"Arial",sans-serif">FESTIVAL HYDRO (LOCAL HYDRO) (FESTH01)</span>
160          </span>
161          <b>
162            <span style="font-size:9.0pt; font-family:"Arial",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:"Arial",sans-serif">FESTH01</span>
170          </span>
171          <b>
172            <span style="font-size:9.0pt; font-family:"Arial",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:"Arial",sans-serif">Notification sent</span>
180          </span>
181          <b>
182            <span style="font-size:9.0pt; font-family:"Arial",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:"Arial",sans-serif">WIGHTMAN TELECOM - FIBRE - LIMITED (WT01)</span>
192          </span>
193          <b>
194            <span style="font-size:9.0pt; font-family:"Arial",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:"Arial",sans-serif">WT01</span>
202          </span>
203          <b>
204            <span style="font-size:9.0pt; font-family:"Arial",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:"Arial",sans-serif">Notification sent</span>
212          </span>
213          <b>
214            <span style="font-size:9.0pt; font-family:"Arial",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:"Arial",sans-serif">CLI FOR ROGERS (ROGWAT01)</span>
224          </span>
225          <b>
226            <span style="font-size:9.0pt; font-family:"Arial",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:"Arial",sans-serif">ROGWAT01</span>
234          </span>
235          <b>
236            <span style="font-size:9.0pt; font-family:"Arial",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:"Arial",sans-serif">Cleared</span>
244          </span>
245          <b>
246            <span style="font-size:9.0pt; font-family:"Arial",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:"Arial",sans-serif">G-TEL FOR BELL CANADA (BCOW01)</span>
256          </span>
257          <b>
258            <span style="font-size:9.0pt; font-family:"Arial",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:"Arial",sans-serif">BCOW01</span>
266          </span>
267          <b>
268            <span style="font-size:9.0pt; font-family:"Arial",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:"Arial",sans-serif">Notification sent</span>
276          </span>
277          <b>
278            <span style="font-size:9.0pt; font-family:"Arial",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:27

I 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:"Arial",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:"Arial",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:"Arial",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:"Arial",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:"Arial",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:"Arial",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:"Arial",sans-serif">ENOW01</span>
106          </span>
107          <b>
108            <span style="font-size:9.0pt; font-family:"Arial",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:"Arial",sans-serif">Notification sent</span>
116          </span>
117          <b>
118            <span style="font-size:9.0pt; font-family:"Arial",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:"Arial",sans-serif">CITY OF STRATFORD (STRATWS01)</span>
128          </span>
129          <b>
130            <span style="font-size:9.0pt; font-family:"Arial",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:"Arial",sans-serif">STRATWS01</span>
138          </span>
139          <b>
140            <span style="font-size:9.0pt; font-family:"Arial",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:"Arial",sans-serif">Notification sent</span>
148          </span>
149          <b>
150            <span style="font-size:9.0pt; font-family:"Arial",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:"Arial",sans-serif">FESTIVAL HYDRO (LOCAL HYDRO) (FESTH01)</span>
160          </span>
161          <b>
162            <span style="font-size:9.0pt; font-family:"Arial",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:"Arial",sans-serif">FESTH01</span>
170          </span>
171          <b>
172            <span style="font-size:9.0pt; font-family:"Arial",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:"Arial",sans-serif">Notification sent</span>
180          </span>
181          <b>
182            <span style="font-size:9.0pt; font-family:"Arial",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:"Arial",sans-serif">WIGHTMAN TELECOM - FIBRE - LIMITED (WT01)</span>
192          </span>
193          <b>
194            <span style="font-size:9.0pt; font-family:"Arial",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:"Arial",sans-serif">WT01</span>
202          </span>
203          <b>
204            <span style="font-size:9.0pt; font-family:"Arial",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:"Arial",sans-serif">Notification sent</span>
212          </span>
213          <b>
214            <span style="font-size:9.0pt; font-family:"Arial",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:"Arial",sans-serif">CLI FOR ROGERS (ROGWAT01)</span>
224          </span>
225          <b>
226            <span style="font-size:9.0pt; font-family:"Arial",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:"Arial",sans-serif">ROGWAT01</span>
234          </span>
235          <b>
236            <span style="font-size:9.0pt; font-family:"Arial",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:"Arial",sans-serif">Cleared</span>
244          </span>
245          <b>
246            <span style="font-size:9.0pt; font-family:"Arial",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:"Arial",sans-serif">G-TEL FOR BELL CANADA (BCOW01)</span>
256          </span>
257          <b>
258            <span style="font-size:9.0pt; font-family:"Arial",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:"Arial",sans-serif">BCOW01</span>
266          </span>
267          <b>
268            <span style="font-size:9.0pt; font-family:"Arial",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:"Arial",sans-serif">Notification sent</span>
276          </span>
277          <b>
278            <span style="font-size:9.0pt; font-family:"Arial",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 of class="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 a span 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 Variable

HTML Variable

This 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:"Arial",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:"Arial",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:"Arial",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:"Arial",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:"Arial",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:"Arial",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:"Arial",sans-serif">ENOW01</span>
106          </span>
107          <b>
108            <span style="font-size:9.0pt; font-family:"Arial",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:"Arial",sans-serif">Notification sent</span>
116          </span>
117          <b>
118            <span style="font-size:9.0pt; font-family:"Arial",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:"Arial",sans-serif">CITY OF STRATFORD (STRATWS01)</span>
128          </span>
129          <b>
130            <span style="font-size:9.0pt; font-family:"Arial",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:"Arial",sans-serif">STRATWS01</span>
138          </span>
139          <b>
140            <span style="font-size:9.0pt; font-family:"Arial",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:"Arial",sans-serif">Notification sent</span>
148          </span>
149          <b>
150            <span style="font-size:9.0pt; font-family:"Arial",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:"Arial",sans-serif">FESTIVAL HYDRO (LOCAL HYDRO) (FESTH01)</span>
160          </span>
161          <b>
162            <span style="font-size:9.0pt; font-family:"Arial",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:"Arial",sans-serif">FESTH01</span>
170          </span>
171          <b>
172            <span style="font-size:9.0pt; font-family:"Arial",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:"Arial",sans-serif">Notification sent</span>
180          </span>
181          <b>
182            <span style="font-size:9.0pt; font-family:"Arial",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:"Arial",sans-serif">WIGHTMAN TELECOM - FIBRE - LIMITED (WT01)</span>
192          </span>
193          <b>
194            <span style="font-size:9.0pt; font-family:"Arial",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:"Arial",sans-serif">WT01</span>
202          </span>
203          <b>
204            <span style="font-size:9.0pt; font-family:"Arial",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:"Arial",sans-serif">Notification sent</span>
212          </span>
213          <b>
214            <span style="font-size:9.0pt; font-family:"Arial",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:"Arial",sans-serif">CLI FOR ROGERS (ROGWAT01)</span>
224          </span>
225          <b>
226            <span style="font-size:9.0pt; font-family:"Arial",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:"Arial",sans-serif">ROGWAT01</span>
234          </span>
235          <b>
236            <span style="font-size:9.0pt; font-family:"Arial",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:"Arial",sans-serif">Cleared</span>
244          </span>
245          <b>
246            <span style="font-size:9.0pt; font-family:"Arial",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:"Arial",sans-serif">G-TEL FOR BELL CANADA (BCOW01)</span>
256          </span>
257          <b>
258            <span style="font-size:9.0pt; font-family:"Arial",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:"Arial",sans-serif">BCOW01</span>
266          </span>
267          <b>
268            <span style="font-size:9.0pt; font-family:"Arial",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:"Arial",sans-serif">Notification sent</span>
276          </span>
277          <b>
278            <span style="font-size:9.0pt; font-family:"Arial",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
Result

Result

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:"Arial",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:"Arial",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:"Arial",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:"Arial",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:"Arial",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:"Arial",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:"Arial",sans-serif">ENOW01</span>
106          </span>
107          <b>
108            <span style="font-size:9.0pt; font-family:"Arial",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:"Arial",sans-serif">Notification sent</span>
116          </span>
117          <b>
118            <span style="font-size:9.0pt; font-family:"Arial",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:"Arial",sans-serif">CITY OF STRATFORD (STRATWS01)</span>
128          </span>
129          <b>
130            <span style="font-size:9.0pt; font-family:"Arial",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:"Arial",sans-serif">STRATWS01</span>
138          </span>
139          <b>
140            <span style="font-size:9.0pt; font-family:"Arial",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:"Arial",sans-serif">Notification sent</span>
148          </span>
149          <b>
150            <span style="font-size:9.0pt; font-family:"Arial",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:"Arial",sans-serif">FESTIVAL HYDRO (LOCAL HYDRO) (FESTH01)</span>
160          </span>
161          <b>
162            <span style="font-size:9.0pt; font-family:"Arial",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:"Arial",sans-serif">FESTH01</span>
170          </span>
171          <b>
172            <span style="font-size:9.0pt; font-family:"Arial",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:"Arial",sans-serif">Notification sent</span>
180          </span>
181          <b>
182            <span style="font-size:9.0pt; font-family:"Arial",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:"Arial",sans-serif">WIGHTMAN TELECOM - FIBRE - LIMITED (WT01)</span>
192          </span>
193          <b>
194            <span style="font-size:9.0pt; font-family:"Arial",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:"Arial",sans-serif">WT01</span>
202          </span>
203          <b>
204            <span style="font-size:9.0pt; font-family:"Arial",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:"Arial",sans-serif">Notification sent</span>
212          </span>
213          <b>
214            <span style="font-size:9.0pt; font-family:"Arial",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:"Arial",sans-serif">CLI FOR ROGERS (ROGWAT01)</span>
224          </span>
225          <b>
226            <span style="font-size:9.0pt; font-family:"Arial",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:"Arial",sans-serif">ROGWAT01</span>
234          </span>
235          <b>
236            <span style="font-size:9.0pt; font-family:"Arial",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:"Arial",sans-serif">Cleared</span>
244          </span>
245          <b>
246            <span style="font-size:9.0pt; font-family:"Arial",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:"Arial",sans-serif">G-TEL FOR BELL CANADA (BCOW01)</span>
256          </span>
257          <b>
258            <span style="font-size:9.0pt; font-family:"Arial",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:"Arial",sans-serif">BCOW01</span>
266          </span>
267          <b>
268            <span style="font-size:9.0pt; font-family:"Arial",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:"Arial",sans-serif">Notification sent</span>
276          </span>
277          <b>
278            <span style="font-size:9.0pt; font-family:"Arial",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

Source https://stackoverflow.com/questions/70826560

QUESTION

A more complex Island & Gaps problem in SQL

Asked 2022-Jan-17 at 13:25

First 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).

example

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.

example

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:

example

I would need this format:

example

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:05

Here'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.

Source https://stackoverflow.com/questions/70732913

QUESTION

react native onPress not working in library in android

Asked 2021-Dec-15 at 06:57

This is the start component and below the render function onPress function works fine.

1import React, { useState, useEffect, useRef } from &quot;react&quot;
2import {
3  StyleSheet,
4  Text,
5  View,
6  Image,
7  TouchableOpacity,
8  TextInput,
9  KeyboardAvoidingView,
10  Keyboard,
11  Button,
12} from &quot;react-native&quot;
13
14import BouncyCheckbox from &quot;react-native-bouncy-checkbox&quot;
15import { SafeAreaView } from &quot;react-native-safe-area-context&quot;
16import { ScrollView, TouchableWithoutFeedback } from &quot;react-native-gesture-handler&quot;
17import { KeyboardAwareScrollView } from &quot;react-native-keyboard-aware-scroll-view&quot;
18import RNPickerSelect from &quot;react-native-picker-select&quot;
19import Animated from &quot;react-native-reanimated&quot;
20import BottomSheet from &quot;reanimated-bottom-sheet&quot;
21import EventBannerSheet from &quot;./event-banner&quot;
22
23export const UserInfoPhone: React.FC = () =&gt; {
24  const userNumberFormRef = useRef&lt;TextInput&gt;()
25  const userNumberNextFormRef = useRef&lt;TextInput&gt;()
26  const userPhoneNumberFormRef = useRef&lt;TextInput&gt;()
27
28  const focusToNextForm = (nextForm: any) =&gt; {
29    nextForm.current.focus()
30  }
31
32  const EssentialAgreementContainer = ({ text }) =&gt; {
33    return (
34      &lt;View style={styles.essentialAgreementContainer}&gt;
35        &lt;View style={styles.essentialSmallBox}&gt;
36          &lt;Text style={styles.essentialAgreementText}&gt;[필수] {text}&lt;/Text&gt;
37          &lt;TouchableOpacity style={styles.okButton}&gt;
38            &lt;Text style={styles.okButtonTitle}&gt;보기&lt;/Text&gt;
39          &lt;/TouchableOpacity&gt;
40        &lt;/View&gt;
41        &lt;BouncyCheckbox
42          size={17}
43          fillColor=&quot;lightgrey&quot;
44          unfillColor=&quot;lightgrey&quot;
45          iconStyle={{ borderColor: &quot;lightgrey&quot; }}
46          textStyle={{ fontFamily: &quot;JosefinSans-Regular&quot; }}
47        /&gt;
48      &lt;/View&gt;
49    )
50  }
51
52  return (
53    &lt;&gt;
54      &lt;SafeAreaView style={styles.container}&gt;
55        &lt;TouchableWithoutFeedback onPress={Keyboard.dismiss}&gt;
56          &lt;KeyboardAwareScrollView&gt;
57            &lt;Image source={require(&quot;./back.png&quot;)} style={styles.backButton} /&gt;
58            &lt;View style={styles.viewTitle}&gt;
59              &lt;Text style={styles.title}&gt;휴대폰으로&lt;/Text&gt;
60              &lt;Text style={styles.title}&gt;간편 본인인증하세요.&lt;/Text&gt;
61            &lt;/View&gt;
62            &lt;View style={styles.subTitleContainer}&gt;
63              &lt;Text style={styles.subTitle}&gt;나중에 할게요&lt;/Text&gt;
64              &lt;TouchableOpacity style={styles.okButton}&gt;
65                &lt;Text style={styles.okButtonTitle}&gt;확인&lt;/Text&gt;
66              &lt;/TouchableOpacity&gt;
67            &lt;/View&gt;
68            &lt;View style={[styles.agreementContainer, styles.shadowProps]}&gt;
69              &lt;View style={styles.conditionContainer}&gt;
70                &lt;Text style={styles.agreementTitle}&gt;본인확인 서비스에 대해 모두 동의하기&lt;/Text&gt;
71                &lt;BouncyCheckbox
72                  size={17}
73                  fillColor=&quot;lightgrey&quot;
74                  unfillColor=&quot;lightgrey&quot;
75                  iconStyle={{ borderColor: &quot;lightgrey&quot; }}
76                  textStyle={{ fontFamily: &quot;JosefinSans-Regular&quot; }}
77                /&gt;
78              &lt;/View&gt;
79              &lt;View style={styles.contour}&gt;&lt;/View&gt;
80              &lt;EssentialAgreementContainer text=&quot;서비스 이용약관 동의&quot; /&gt;
81              &lt;EssentialAgreementContainer text=&quot;통신사 이용약관 동의&quot; /&gt;
82              &lt;EssentialAgreementContainer text=&quot;개인 정보 수집 및 이용 동의&quot; /&gt;
83              &lt;EssentialAgreementContainer text=&quot;개인 제어보 제공/위탁 동의&quot; /&gt;
84              &lt;EssentialAgreementContainer text=&quot;고유식별 정보 처리&quot; /&gt;
85            &lt;/View&gt;
86            &lt;View style={styles.infoForms}&gt;
87              &lt;View style={styles.nameFormContainer}&gt;
88                &lt;Text style={styles.userInfo}&gt;성명&lt;/Text&gt;
89                &lt;TextInput
90                  style={styles.nameForm}
91                  onSubmitEditing={() =&gt; {
92                    focusToNextForm(userNumberFormRef)
93                  }}
94                /&gt;
95              &lt;/View&gt;
96              &lt;View style={styles.personNumberFormContainer}&gt;
97                &lt;Text style={styles.userInfo}&gt;주민등록번호 (외국인등록번호)&lt;/Text&gt;
98                &lt;View style={styles.userNumberFormContainer}&gt;
99                  &lt;TextInput
100                    style={styles.userNumberForm}
101                    maxLength={6}
102                    placeholder=&quot;960101&quot;
103                    onSubmitEditing={() =&gt; {
104                      focusToNextForm(userNumberNextFormRef)
105                    }}
106                    ref={userNumberFormRef}
107                  /&gt;
108                  &lt;Text style={{ fontSize: 20 }}&gt;-&lt;/Text&gt;
109                  &lt;TextInput
110                    style={styles.userSecondNumberForm}
111                    maxLength={1}
112                    ref={userNumberNextFormRef}
113                    onSubmitEditing={() =&gt; {
114                      focusToNextForm(userPhoneNumberFormRef)
115                    }}
116                  /&gt;
117                &lt;/View&gt;
118              &lt;/View&gt;
119              &lt;View style={styles.phoneFormContainer}&gt;
120                &lt;Text style={styles.userInfo}&gt;휴대폰번호&lt;/Text&gt;
121                &lt;View style={styles.phoneForms}&gt;
122                  &lt;View style={styles.telecome}&gt;
123                    &lt;RNPickerSelect
124                      style={{ inputAndroid: { color: &quot;black&quot;, padding: 0, height: 20 } }}
125                      useNativeAndroidPickerStyle={false}
126                      onValueChange={(value) =&gt; console.log(value)}
127                      placeholder={{ label: &quot;통신사&quot; }}
128                      items={[
129                        { label: &quot;SKT&quot;, value: &quot;SKT&quot; },
130                        { label: &quot;KT&quot;, value: &quot;KT&quot; },
131                        { label: &quot;LG U+&quot;, value: &quot;LG U+&quot; },
132                        { label: &quot;SKT알뜰폰&quot;, value: &quot;SKT알뜰폰&quot; },
133                        { label: &quot;KT알뜰폰&quot;, value: &quot;KT알뜰폰&quot; },
134                        { label: &quot;LG U+알뜰폰&quot;, value: &quot;LG U+알뜰폰&quot; },
135                      ]}
136                    /&gt;
137                  &lt;/View&gt;
138                  &lt;TextInput
139                    style={styles.phoneForm}
140                    placeholder=&quot;010-1234-5678&quot;
141                    ref={userPhoneNumberFormRef}
142                  /&gt;
143                &lt;/View&gt;
144              &lt;/View&gt;
145            &lt;/View&gt;
146            &lt;TouchableOpacity style={styles.certificationButton}&gt;
147              &lt;Text style={styles.certificationText}&gt;인증하기&lt;/Text&gt;
148            &lt;/TouchableOpacity&gt;
149          &lt;/KeyboardAwareScrollView&gt;
150        &lt;/TouchableWithoutFeedback&gt;
151      &lt;/SafeAreaView&gt;
152      &lt;EventBannerSheet /&gt;
153    &lt;/&gt;
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 &quot;react&quot;
2import {
3  StyleSheet,
4  Text,
5  View,
6  Image,
7  TouchableOpacity,
8  TextInput,
9  KeyboardAvoidingView,
10  Keyboard,
11  Button,
12} from &quot;react-native&quot;
13
14import BouncyCheckbox from &quot;react-native-bouncy-checkbox&quot;
15import { SafeAreaView } from &quot;react-native-safe-area-context&quot;
16import { ScrollView, TouchableWithoutFeedback } from &quot;react-native-gesture-handler&quot;
17import { KeyboardAwareScrollView } from &quot;react-native-keyboard-aware-scroll-view&quot;
18import RNPickerSelect from &quot;react-native-picker-select&quot;
19import Animated from &quot;react-native-reanimated&quot;
20import BottomSheet from &quot;reanimated-bottom-sheet&quot;
21import EventBannerSheet from &quot;./event-banner&quot;
22
23export const UserInfoPhone: React.FC = () =&gt; {
24  const userNumberFormRef = useRef&lt;TextInput&gt;()
25  const userNumberNextFormRef = useRef&lt;TextInput&gt;()
26  const userPhoneNumberFormRef = useRef&lt;TextInput&gt;()
27
28  const focusToNextForm = (nextForm: any) =&gt; {
29    nextForm.current.focus()
30  }
31
32  const EssentialAgreementContainer = ({ text }) =&gt; {
33    return (
34      &lt;View style={styles.essentialAgreementContainer}&gt;
35        &lt;View style={styles.essentialSmallBox}&gt;
36          &lt;Text style={styles.essentialAgreementText}&gt;[필수] {text}&lt;/Text&gt;
37          &lt;TouchableOpacity style={styles.okButton}&gt;
38            &lt;Text style={styles.okButtonTitle}&gt;보기&lt;/Text&gt;
39          &lt;/TouchableOpacity&gt;
40        &lt;/View&gt;
41        &lt;BouncyCheckbox
42          size={17}
43          fillColor=&quot;lightgrey&quot;
44          unfillColor=&quot;lightgrey&quot;
45          iconStyle={{ borderColor: &quot;lightgrey&quot; }}
46          textStyle={{ fontFamily: &quot;JosefinSans-Regular&quot; }}
47        /&gt;
48      &lt;/View&gt;
49    )
50  }
51
52  return (
53    &lt;&gt;
54      &lt;SafeAreaView style={styles.container}&gt;
55        &lt;TouchableWithoutFeedback onPress={Keyboard.dismiss}&gt;
56          &lt;KeyboardAwareScrollView&gt;
57            &lt;Image source={require(&quot;./back.png&quot;)} style={styles.backButton} /&gt;
58            &lt;View style={styles.viewTitle}&gt;
59              &lt;Text style={styles.title}&gt;휴대폰으로&lt;/Text&gt;
60              &lt;Text style={styles.title}&gt;간편 본인인증하세요.&lt;/Text&gt;
61            &lt;/View&gt;
62            &lt;View style={styles.subTitleContainer}&gt;
63              &lt;Text style={styles.subTitle}&gt;나중에 할게요&lt;/Text&gt;
64              &lt;TouchableOpacity style={styles.okButton}&gt;
65                &lt;Text style={styles.okButtonTitle}&gt;확인&lt;/Text&gt;
66              &lt;/TouchableOpacity&gt;
67            &lt;/View&gt;
68            &lt;View style={[styles.agreementContainer, styles.shadowProps]}&gt;
69              &lt;View style={styles.conditionContainer}&gt;
70                &lt;Text style={styles.agreementTitle}&gt;본인확인 서비스에 대해 모두 동의하기&lt;/Text&gt;
71                &lt;BouncyCheckbox
72                  size={17}
73                  fillColor=&quot;lightgrey&quot;
74                  unfillColor=&quot;lightgrey&quot;
75                  iconStyle={{ borderColor: &quot;lightgrey&quot; }}
76                  textStyle={{ fontFamily: &quot;JosefinSans-Regular&quot; }}
77                /&gt;
78              &lt;/View&gt;
79              &lt;View style={styles.contour}&gt;&lt;/View&gt;
80              &lt;EssentialAgreementContainer text=&quot;서비스 이용약관 동의&quot; /&gt;
81              &lt;EssentialAgreementContainer text=&quot;통신사 이용약관 동의&quot; /&gt;
82              &lt;EssentialAgreementContainer text=&quot;개인 정보 수집 및 이용 동의&quot; /&gt;
83              &lt;EssentialAgreementContainer text=&quot;개인 제어보 제공/위탁 동의&quot; /&gt;
84              &lt;EssentialAgreementContainer text=&quot;고유식별 정보 처리&quot; /&gt;
85            &lt;/View&gt;
86            &lt;View style={styles.infoForms}&gt;
87              &lt;View style={styles.nameFormContainer}&gt;
88                &lt;Text style={styles.userInfo}&gt;성명&lt;/Text&gt;
89                &lt;TextInput
90                  style={styles.nameForm}
91                  onSubmitEditing={() =&gt; {
92                    focusToNextForm(userNumberFormRef)
93                  }}
94                /&gt;
95              &lt;/View&gt;
96              &lt;View style={styles.personNumberFormContainer}&gt;
97                &lt;Text style={styles.userInfo}&gt;주민등록번호 (외국인등록번호)&lt;/Text&gt;
98                &lt;View style={styles.userNumberFormContainer}&gt;
99                  &lt;TextInput
100                    style={styles.userNumberForm}
101                    maxLength={6}
102                    placeholder=&quot;960101&quot;
103                    onSubmitEditing={() =&gt; {
104                      focusToNextForm(userNumberNextFormRef)
105                    }}
106                    ref={userNumberFormRef}
107                  /&gt;
108                  &lt;Text style={{ fontSize: 20 }}&gt;-&lt;/Text&gt;
109                  &lt;TextInput
110                    style={styles.userSecondNumberForm}
111                    maxLength={1}
112                    ref={userNumberNextFormRef}
113                    onSubmitEditing={() =&gt; {
114                      focusToNextForm(userPhoneNumberFormRef)
115                    }}
116                  /&gt;
117                &lt;/View&gt;
118              &lt;/View&gt;
119              &lt;View style={styles.phoneFormContainer}&gt;
120                &lt;Text style={styles.userInfo}&gt;휴대폰번호&lt;/Text&gt;
121                &lt;View style={styles.phoneForms}&gt;
122                  &lt;View style={styles.telecome}&gt;
123                    &lt;RNPickerSelect
124                      style={{ inputAndroid: { color: &quot;black&quot;, padding: 0, height: 20 } }}
125                      useNativeAndroidPickerStyle={false}
126                      onValueChange={(value) =&gt; console.log(value)}
127                      placeholder={{ label: &quot;통신사&quot; }}
128                      items={[
129                        { label: &quot;SKT&quot;, value: &quot;SKT&quot; },
130                        { label: &quot;KT&quot;, value: &quot;KT&quot; },
131                        { label: &quot;LG U+&quot;, value: &quot;LG U+&quot; },
132                        { label: &quot;SKT알뜰폰&quot;, value: &quot;SKT알뜰폰&quot; },
133                        { label: &quot;KT알뜰폰&quot;, value: &quot;KT알뜰폰&quot; },
134                        { label: &quot;LG U+알뜰폰&quot;, value: &quot;LG U+알뜰폰&quot; },
135                      ]}
136                    /&gt;
137                  &lt;/View&gt;
138                  &lt;TextInput
139                    style={styles.phoneForm}
140                    placeholder=&quot;010-1234-5678&quot;
141                    ref={userPhoneNumberFormRef}
142                  /&gt;
143                &lt;/View&gt;
144              &lt;/View&gt;
145            &lt;/View&gt;
146            &lt;TouchableOpacity style={styles.certificationButton}&gt;
147              &lt;Text style={styles.certificationText}&gt;인증하기&lt;/Text&gt;
148            &lt;/TouchableOpacity&gt;
149          &lt;/KeyboardAwareScrollView&gt;
150        &lt;/TouchableWithoutFeedback&gt;
151      &lt;/SafeAreaView&gt;
152      &lt;EventBannerSheet /&gt;
153    &lt;/&gt;
154  )
155}
156import React, { useRef } from &quot;react&quot;
157import { StyleSheet, Text, View, Image, TouchableOpacity } from &quot;react-native&quot;
158import BottomSheet from &quot;reanimated-bottom-sheet&quot;
159
160const EventBannerSheet: React.FC = () =&gt; {
161  const sheetRef = useRef(null)
162
163  const consoleHello = () =&gt; {
164    console.log(&quot;helloooooooo!!!!&quot;)
165  }
166
167  const renderContent = () =&gt; (
168    &lt;View style={styles.bottomSheet}&gt;
169      &lt;View style={styles.sheetTextContainer}&gt;
170        &lt;Text
171          style={styles.sheetText}
172          onPress={() =&gt; {
173            consoleHello()
174          }}
175        &gt;
176          EVENT BANNER
177        &lt;/Text&gt;
178        &lt;Text style={styles.sheetText}&gt;IMG&lt;/Text&gt;
179      &lt;/View&gt;
180      &lt;View style={styles.sheetCloseContainer}&gt;
181        &lt;TouchableOpacity
182          onPress={() =&gt; {
183            console.log(&quot;helloMaster123&quot;)
184          }}
185        &gt;
186          &lt;Text style={{ color: &quot;blue&quot; }}&gt;오늘 하루 보지않기&lt;/Text&gt;
187        &lt;/TouchableOpacity&gt;
188        &lt;TouchableOpacity onPress={() =&gt; sheetRef.current.snapTo(2)}&gt;
189          &lt;Text&gt;닫기&lt;/Text&gt;
190        &lt;/TouchableOpacity&gt;
191      &lt;/View&gt;
192    &lt;/View&gt;
193  )
194
195  return (
196    &lt;&gt;
197      &lt;BottomSheet
198        initialSnap={1}
199        ref={sheetRef}
200        snapPoints={[450, 350, 0]}
201        borderRadius={10}
202        renderContent={renderContent}
203      /&gt;
204    &lt;/&gt;
205  )
206}
207

and this is stylesheet of EventBannerSheet

1import React, { useState, useEffect, useRef } from &quot;react&quot;
2import {
3  StyleSheet,
4  Text,
5  View,
6  Image,
7  TouchableOpacity,
8  TextInput,
9  KeyboardAvoidingView,
10  Keyboard,
11  Button,
12} from &quot;react-native&quot;
13
14import BouncyCheckbox from &quot;react-native-bouncy-checkbox&quot;
15import { SafeAreaView } from &quot;react-native-safe-area-context&quot;
16import { ScrollView, TouchableWithoutFeedback } from &quot;react-native-gesture-handler&quot;
17import { KeyboardAwareScrollView } from &quot;react-native-keyboard-aware-scroll-view&quot;
18import RNPickerSelect from &quot;react-native-picker-select&quot;
19import Animated from &quot;react-native-reanimated&quot;
20import BottomSheet from &quot;reanimated-bottom-sheet&quot;
21import EventBannerSheet from &quot;./event-banner&quot;
22
23export const UserInfoPhone: React.FC = () =&gt; {
24  const userNumberFormRef = useRef&lt;TextInput&gt;()
25  const userNumberNextFormRef = useRef&lt;TextInput&gt;()
26  const userPhoneNumberFormRef = useRef&lt;TextInput&gt;()
27
28  const focusToNextForm = (nextForm: any) =&gt; {
29    nextForm.current.focus()
30  }
31
32  const EssentialAgreementContainer = ({ text }) =&gt; {
33    return (
34      &lt;View style={styles.essentialAgreementContainer}&gt;
35        &lt;View style={styles.essentialSmallBox}&gt;
36          &lt;Text style={styles.essentialAgreementText}&gt;[필수] {text}&lt;/Text&gt;
37          &lt;TouchableOpacity style={styles.okButton}&gt;
38            &lt;Text style={styles.okButtonTitle}&gt;보기&lt;/Text&gt;
39          &lt;/TouchableOpacity&gt;
40        &lt;/View&gt;
41        &lt;BouncyCheckbox
42          size={17}
43          fillColor=&quot;lightgrey&quot;
44          unfillColor=&quot;lightgrey&quot;
45          iconStyle={{ borderColor: &quot;lightgrey&quot; }}
46          textStyle={{ fontFamily: &quot;JosefinSans-Regular&quot; }}
47        /&gt;
48      &lt;/View&gt;
49    )
50  }
51
52  return (
53    &lt;&gt;
54      &lt;SafeAreaView style={styles.container}&gt;
55        &lt;TouchableWithoutFeedback onPress={Keyboard.dismiss}&gt;
56          &lt;KeyboardAwareScrollView&gt;
57            &lt;Image source={require(&quot;./back.png&quot;)} style={styles.backButton} /&gt;
58            &lt;View style={styles.viewTitle}&gt;
59              &lt;Text style={styles.title}&gt;휴대폰으로&lt;/Text&gt;
60              &lt;Text style={styles.title}&gt;간편 본인인증하세요.&lt;/Text&gt;
61            &lt;/View&gt;
62            &lt;View style={styles.subTitleContainer}&gt;
63              &lt;Text style={styles.subTitle}&gt;나중에 할게요&lt;/Text&gt;
64              &lt;TouchableOpacity style={styles.okButton}&gt;
65                &lt;Text style={styles.okButtonTitle}&gt;확인&lt;/Text&gt;
66              &lt;/TouchableOpacity&gt;
67            &lt;/View&gt;
68            &lt;View style={[styles.agreementContainer, styles.shadowProps]}&gt;
69              &lt;View style={styles.conditionContainer}&gt;
70                &lt;Text style={styles.agreementTitle}&gt;본인확인 서비스에 대해 모두 동의하기&lt;/Text&gt;
71                &lt;BouncyCheckbox
72                  size={17}
73                  fillColor=&quot;lightgrey&quot;
74                  unfillColor=&quot;lightgrey&quot;
75                  iconStyle={{ borderColor: &quot;lightgrey&quot; }}
76                  textStyle={{ fontFamily: &quot;JosefinSans-Regular&quot; }}
77                /&gt;
78              &lt;/View&gt;
79              &lt;View style={styles.contour}&gt;&lt;/View&gt;
80              &lt;EssentialAgreementContainer text=&quot;서비스 이용약관 동의&quot; /&gt;
81              &lt;EssentialAgreementContainer text=&quot;통신사 이용약관 동의&quot; /&gt;
82              &lt;EssentialAgreementContainer text=&quot;개인 정보 수집 및 이용 동의&quot; /&gt;
83              &lt;EssentialAgreementContainer text=&quot;개인 제어보 제공/위탁 동의&quot; /&gt;
84              &lt;EssentialAgreementContainer text=&quot;고유식별 정보 처리&quot; /&gt;
85            &lt;/View&gt;
86            &lt;View style={styles.infoForms}&gt;
87              &lt;View style={styles.nameFormContainer}&gt;
88                &lt;Text style={styles.userInfo}&gt;성명&lt;/Text&gt;
89                &lt;TextInput
90                  style={styles.nameForm}
91                  onSubmitEditing={() =&gt; {
92                    focusToNextForm(userNumberFormRef)
93                  }}
94                /&gt;
95              &lt;/View&gt;
96              &lt;View style={styles.personNumberFormContainer}&gt;
97                &lt;Text style={styles.userInfo}&gt;주민등록번호 (외국인등록번호)&lt;/Text&gt;
98                &lt;View style={styles.userNumberFormContainer}&gt;
99                  &lt;TextInput
100                    style={styles.userNumberForm}
101                    maxLength={6}
102                    placeholder=&quot;960101&quot;
103                    onSubmitEditing={() =&gt; {
104                      focusToNextForm(userNumberNextFormRef)
105                    }}
106                    ref={userNumberFormRef}
107                  /&gt;
108                  &lt;Text style={{ fontSize: 20 }}&gt;-&lt;/Text&gt;
109                  &lt;TextInput
110                    style={styles.userSecondNumberForm}
111                    maxLength={1}
112                    ref={userNumberNextFormRef}
113                    onSubmitEditing={() =&gt; {
114                      focusToNextForm(userPhoneNumberFormRef)
115                    }}
116                  /&gt;
117                &lt;/View&gt;
118              &lt;/View&gt;
119              &lt;View style={styles.phoneFormContainer}&gt;
120                &lt;Text style={styles.userInfo}&gt;휴대폰번호&lt;/Text&gt;
121                &lt;View style={styles.phoneForms}&gt;
122                  &lt;View style={styles.telecome}&gt;
123                    &lt;RNPickerSelect
124                      style={{ inputAndroid: { color: &quot;black&quot;, padding: 0, height: 20 } }}
125                      useNativeAndroidPickerStyle={false}
126                      onValueChange={(value) =&gt; console.log(value)}
127                      placeholder={{ label: &quot;통신사&quot; }}
128                      items={[
129                        { label: &quot;SKT&quot;, value: &quot;SKT&quot; },
130                        { label: &quot;KT&quot;, value: &quot;KT&quot; },
131                        { label: &quot;LG U+&quot;, value: &quot;LG U+&quot; },
132                        { label: &quot;SKT알뜰폰&quot;, value: &quot;SKT알뜰폰&quot; },
133                        { label: &quot;KT알뜰폰&quot;, value: &quot;KT알뜰폰&quot; },
134                        { label: &quot;LG U+알뜰폰&quot;, value: &quot;LG U+알뜰폰&quot; },
135                      ]}
136                    /&gt;
137                  &lt;/View&gt;
138                  &lt;TextInput
139                    style={styles.phoneForm}
140                    placeholder=&quot;010-1234-5678&quot;
141                    ref={userPhoneNumberFormRef}
142                  /&gt;
143                &lt;/View&gt;
144              &lt;/View&gt;
145            &lt;/View&gt;
146            &lt;TouchableOpacity style={styles.certificationButton}&gt;
147              &lt;Text style={styles.certificationText}&gt;인증하기&lt;/Text&gt;
148            &lt;/TouchableOpacity&gt;
149          &lt;/KeyboardAwareScrollView&gt;
150        &lt;/TouchableWithoutFeedback&gt;
151      &lt;/SafeAreaView&gt;
152      &lt;EventBannerSheet /&gt;
153    &lt;/&gt;
154  )
155}
156import React, { useRef } from &quot;react&quot;
157import { StyleSheet, Text, View, Image, TouchableOpacity } from &quot;react-native&quot;
158import BottomSheet from &quot;reanimated-bottom-sheet&quot;
159
160const EventBannerSheet: React.FC = () =&gt; {
161  const sheetRef = useRef(null)
162
163  const consoleHello = () =&gt; {
164    console.log(&quot;helloooooooo!!!!&quot;)
165  }
166
167  const renderContent = () =&gt; (
168    &lt;View style={styles.bottomSheet}&gt;
169      &lt;View style={styles.sheetTextContainer}&gt;
170        &lt;Text
171          style={styles.sheetText}
172          onPress={() =&gt; {
173            consoleHello()
174          }}
175        &gt;
176          EVENT BANNER
177        &lt;/Text&gt;
178        &lt;Text style={styles.sheetText}&gt;IMG&lt;/Text&gt;
179      &lt;/View&gt;
180      &lt;View style={styles.sheetCloseContainer}&gt;
181        &lt;TouchableOpacity
182          onPress={() =&gt; {
183            console.log(&quot;helloMaster123&quot;)
184          }}
185        &gt;
186          &lt;Text style={{ color: &quot;blue&quot; }}&gt;오늘 하루 보지않기&lt;/Text&gt;
187        &lt;/TouchableOpacity&gt;
188        &lt;TouchableOpacity onPress={() =&gt; sheetRef.current.snapTo(2)}&gt;
189          &lt;Text&gt;닫기&lt;/Text&gt;
190        &lt;/TouchableOpacity&gt;
191      &lt;/View&gt;
192    &lt;/View&gt;
193  )
194
195  return (
196    &lt;&gt;
197      &lt;BottomSheet
198        initialSnap={1}
199        ref={sheetRef}
200        snapPoints={[450, 350, 0]}
201        borderRadius={10}
202        renderContent={renderContent}
203      /&gt;
204    &lt;/&gt;
205  )
206}
207
208const styles = StyleSheet.create({
209  bottomSheet: {
210    backgroundColor: &quot;white&quot;,
211    padding: 25,
212    height: 440,
213  },
214
215  sheetTextContainer: {
216    height: 270,
217    alignItems: &quot;center&quot;,
218    justifyContent: &quot;center&quot;,
219    backgroundColor: &quot;#d3d3d3&quot;,
220    borderRadius: 10,
221  },
222
223  sheetText: {
224    fontSize: 30,
225    color: &quot;white&quot;,
226  },
227
228  sheetCloseContainer: {
229    flexDirection: &quot;row&quot;,
230    justifyContent: &quot;space-between&quot;,
231    marginTop: 20,
232  },
233})
234

ANSWER

Answered 2021-Dec-15 at 05:40
1import React, { useState, useEffect, useRef } from &quot;react&quot;
2import {
3  StyleSheet,
4  Text,
5  View,
6  Image,
7  TouchableOpacity,
8  TextInput,
9  KeyboardAvoidingView,
10  Keyboard,
11  Button,
12} from &quot;react-native&quot;
13
14import BouncyCheckbox from &quot;react-native-bouncy-checkbox&quot;
15import { SafeAreaView } from &quot;react-native-safe-area-context&quot;
16import { ScrollView, TouchableWithoutFeedback } from &quot;react-native-gesture-handler&quot;
17import { KeyboardAwareScrollView } from &quot;react-native-keyboard-aware-scroll-view&quot;
18import RNPickerSelect from &quot;react-native-picker-select&quot;
19import Animated from &quot;react-native-reanimated&quot;
20import BottomSheet from &quot;reanimated-bottom-sheet&quot;
21import EventBannerSheet from &quot;./event-banner&quot;
22
23export const UserInfoPhone: React.FC = () =&gt; {
24  const userNumberFormRef = useRef&lt;TextInput&gt;()
25  const userNumberNextFormRef = useRef&lt;TextInput&gt;()
26  const userPhoneNumberFormRef = useRef&lt;TextInput&gt;()
27
28  const focusToNextForm = (nextForm: any) =&gt; {
29    nextForm.current.focus()
30  }
31
32  const EssentialAgreementContainer = ({ text }) =&gt; {
33    return (
34      &lt;View style={styles.essentialAgreementContainer}&gt;
35        &lt;View style={styles.essentialSmallBox}&gt;
36          &lt;Text style={styles.essentialAgreementText}&gt;[필수] {text}&lt;/Text&gt;
37          &lt;TouchableOpacity style={styles.okButton}&gt;
38            &lt;Text style={styles.okButtonTitle}&gt;보기&lt;/Text&gt;
39          &lt;/TouchableOpacity&gt;
40        &lt;/View&gt;
41        &lt;BouncyCheckbox
42          size={17}
43          fillColor=&quot;lightgrey&quot;
44          unfillColor=&quot;lightgrey&quot;
45          iconStyle={{ borderColor: &quot;lightgrey&quot; }}
46          textStyle={{ fontFamily: &quot;JosefinSans-Regular&quot; }}
47        /&gt;
48      &lt;/View&gt;
49    )
50  }
51
52  return (
53    &lt;&gt;
54      &lt;SafeAreaView style={styles.container}&gt;
55        &lt;TouchableWithoutFeedback onPress={Keyboard.dismiss}&gt;
56          &lt;KeyboardAwareScrollView&gt;
57            &lt;Image source={require(&quot;./back.png&quot;)} style={styles.backButton} /&gt;
58            &lt;View style={styles.viewTitle}&gt;
59              &lt;Text style={styles.title}&gt;휴대폰으로&lt;/Text&gt;
60              &lt;Text style={styles.title}&gt;간편 본인인증하세요.&lt;/Text&gt;
61            &lt;/View&gt;
62            &lt;View style={styles.subTitleContainer}&gt;
63              &lt;Text style={styles.subTitle}&gt;나중에 할게요&lt;/Text&gt;
64              &lt;TouchableOpacity style={styles.okButton}&gt;
65                &lt;Text style={styles.okButtonTitle}&gt;확인&lt;/Text&gt;
66              &lt;/TouchableOpacity&gt;
67            &lt;/View&gt;
68            &lt;View style={[styles.agreementContainer, styles.shadowProps]}&gt;
69              &lt;View style={styles.conditionContainer}&gt;
70                &lt;Text style={styles.agreementTitle}&gt;본인확인 서비스에 대해 모두 동의하기&lt;/Text&gt;
71                &lt;BouncyCheckbox
72                  size={17}
73                  fillColor=&quot;lightgrey&quot;
74                  unfillColor=&quot;lightgrey&quot;
75                  iconStyle={{ borderColor: &quot;lightgrey&quot; }}
76                  textStyle={{ fontFamily: &quot;JosefinSans-Regular&quot; }}
77                /&gt;
78              &lt;/View&gt;
79              &lt;View style={styles.contour}&gt;&lt;/View&gt;
80              &lt;EssentialAgreementContainer text=&quot;서비스 이용약관 동의&quot; /&gt;
81              &lt;EssentialAgreementContainer text=&quot;통신사 이용약관 동의&quot; /&gt;
82              &lt;EssentialAgreementContainer text=&quot;개인 정보 수집 및 이용 동의&quot; /&gt;
83              &lt;EssentialAgreementContainer text=&quot;개인 제어보 제공/위탁 동의&quot; /&gt;
84              &lt;EssentialAgreementContainer text=&quot;고유식별 정보 처리&quot; /&gt;
85            &lt;/View&gt;
86            &lt;View style={styles.infoForms}&gt;
87              &lt;View style={styles.nameFormContainer}&gt;
88                &lt;Text style={styles.userInfo}&gt;성명&lt;/Text&gt;
89                &lt;TextInput
90                  style={styles.nameForm}
91                  onSubmitEditing={() =&gt; {
92                    focusToNextForm(userNumberFormRef)
93                  }}
94                /&gt;
95              &lt;/View&gt;
96              &lt;View style={styles.personNumberFormContainer}&gt;
97                &lt;Text style={styles.userInfo}&gt;주민등록번호 (외국인등록번호)&lt;/Text&gt;
98                &lt;View style={styles.userNumberFormContainer}&gt;
99                  &lt;TextInput
100                    style={styles.userNumberForm}
101                    maxLength={6}
102                    placeholder=&quot;960101&quot;
103                    onSubmitEditing={() =&gt; {
104                      focusToNextForm(userNumberNextFormRef)
105                    }}
106                    ref={userNumberFormRef}
107                  /&gt;
108                  &lt;Text style={{ fontSize: 20 }}&gt;-&lt;/Text&gt;
109                  &lt;TextInput
110                    style={styles.userSecondNumberForm}
111                    maxLength={1}
112                    ref={userNumberNextFormRef}
113                    onSubmitEditing={() =&gt; {
114                      focusToNextForm(userPhoneNumberFormRef)
115                    }}
116                  /&gt;
117                &lt;/View&gt;
118              &lt;/View&gt;
119              &lt;View style={styles.phoneFormContainer}&gt;
120                &lt;Text style={styles.userInfo}&gt;휴대폰번호&lt;/Text&gt;
121                &lt;View style={styles.phoneForms}&gt;
122                  &lt;View style={styles.telecome}&gt;
123                    &lt;RNPickerSelect
124                      style={{ inputAndroid: { color: &quot;black&quot;, padding: 0, height: 20 } }}
125                      useNativeAndroidPickerStyle={false}
126                      onValueChange={(value) =&gt; console.log(value)}
127                      placeholder={{ label: &quot;통신사&quot; }}
128                      items={[
129                        { label: &quot;SKT&quot;, value: &quot;SKT&quot; },
130                        { label: &quot;KT&quot;, value: &quot;KT&quot; },
131                        { label: &quot;LG U+&quot;, value: &quot;LG U+&quot; },
132                        { label: &quot;SKT알뜰폰&quot;, value: &quot;SKT알뜰폰&quot; },
133                        { label: &quot;KT알뜰폰&quot;, value: &quot;KT알뜰폰&quot; },
134                        { label: &quot;LG U+알뜰폰&quot;, value: &quot;LG U+알뜰폰&quot; },
135                      ]}
136                    /&gt;
137                  &lt;/View&gt;
138                  &lt;TextInput
139                    style={styles.phoneForm}
140                    placeholder=&quot;010-1234-5678&quot;
141                    ref={userPhoneNumberFormRef}
142                  /&gt;
143                &lt;/View&gt;
144              &lt;/View&gt;
145            &lt;/View&gt;
146            &lt;TouchableOpacity style={styles.certificationButton}&gt;
147              &lt;Text style={styles.certificationText}&gt;인증하기&lt;/Text&gt;
148            &lt;/TouchableOpacity&gt;
149          &lt;/KeyboardAwareScrollView&gt;
150        &lt;/TouchableWithoutFeedback&gt;
151      &lt;/SafeAreaView&gt;
152      &lt;EventBannerSheet /&gt;
153    &lt;/&gt;
154  )
155}
156import React, { useRef } from &quot;react&quot;
157import { StyleSheet, Text, View, Image, TouchableOpacity } from &quot;react-native&quot;
158import BottomSheet from &quot;reanimated-bottom-sheet&quot;
159
160const EventBannerSheet: React.FC = () =&gt; {
161  const sheetRef = useRef(null)
162
163  const consoleHello = () =&gt; {
164    console.log(&quot;helloooooooo!!!!&quot;)
165  }
166
167  const renderContent = () =&gt; (
168    &lt;View style={styles.bottomSheet}&gt;
169      &lt;View style={styles.sheetTextContainer}&gt;
170        &lt;Text
171          style={styles.sheetText}
172          onPress={() =&gt; {
173            consoleHello()
174          }}
175        &gt;
176          EVENT BANNER
177        &lt;/Text&gt;
178        &lt;Text style={styles.sheetText}&gt;IMG&lt;/Text&gt;
179      &lt;/View&gt;
180      &lt;View style={styles.sheetCloseContainer}&gt;
181        &lt;TouchableOpacity
182          onPress={() =&gt; {
183            console.log(&quot;helloMaster123&quot;)
184          }}
185        &gt;
186          &lt;Text style={{ color: &quot;blue&quot; }}&gt;오늘 하루 보지않기&lt;/Text&gt;
187        &lt;/TouchableOpacity&gt;
188        &lt;TouchableOpacity onPress={() =&gt; sheetRef.current.snapTo(2)}&gt;
189          &lt;Text&gt;닫기&lt;/Text&gt;
190        &lt;/TouchableOpacity&gt;
191      &lt;/View&gt;
192    &lt;/View&gt;
193  )
194
195  return (
196    &lt;&gt;
197      &lt;BottomSheet
198        initialSnap={1}
199        ref={sheetRef}
200        snapPoints={[450, 350, 0]}
201        borderRadius={10}
202        renderContent={renderContent}
203      /&gt;
204    &lt;/&gt;
205  )
206}
207
208const styles = StyleSheet.create({
209  bottomSheet: {
210    backgroundColor: &quot;white&quot;,
211    padding: 25,
212    height: 440,
213  },
214
215  sheetTextContainer: {
216    height: 270,
217    alignItems: &quot;center&quot;,
218    justifyContent: &quot;center&quot;,
219    backgroundColor: &quot;#d3d3d3&quot;,
220    borderRadius: 10,
221  },
222
223  sheetText: {
224    fontSize: 30,
225    color: &quot;white&quot;,
226  },
227
228  sheetCloseContainer: {
229    flexDirection: &quot;row&quot;,
230    justifyContent: &quot;space-between&quot;,
231    marginTop: 20,
232  },
233})
234    &lt;View style={styles.bottomSheet}&gt;
235        &lt;View style={styles.sheetTextContainer}&gt;
236            &lt;TouchableOpacity
237                style={styles.sheetText}
238                onPress={() =&gt; {
239                    consoleHello()
240                }}
241            &gt;
242                &lt;Text style={{ color: &quot;black&quot; }}&gt;EVENT BANNER&lt;/Text&gt;
243            &lt;/TouchableOpacity&gt;
244            &lt;Text style={styles.sheetText}&gt;IMG&lt;/Text&gt;
245        &lt;/View&gt;
246        &lt;View style={styles.sheetCloseContainer}&gt;
247            &lt;TouchableOpacity
248                onPress={() =&gt; {
249                    console.log(&quot;helloMaster123&quot;)
250                }}&gt;
251                &lt;Text style={{ color: &quot;blue&quot; }}&gt;오늘 하루 보지않기&lt;/Text&gt;
252            &lt;/TouchableOpacity&gt;
253            &lt;TouchableOpacity onPress={() =&gt; sheetRef.current.snapTo(2)}&gt;
254                &lt;Text&gt;닫기&lt;/Text&gt;
255            &lt;/TouchableOpacity&gt;
256        &lt;/View&gt;
257    &lt;/View&gt;
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.

Source https://stackoverflow.com/questions/70358438

QUESTION

Read a section in FHIR Document Reference Data

Asked 2021-Dec-08 at 14:34

Is 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&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt; 
2&lt;ClinicalDocument xmlns=&quot;urn:hl7-org:v3&quot; xmlns:voc=&quot;xyz&quot; xmlns:sdtc=&quot;xyz&quot; xmlns:xsi=&quot;xyz&quot;&gt;
3    &lt;realmCode code=&quot;US&quot;/&gt;       
4            &lt;assignedCustodian&gt;
5              &lt;representedCustodianOrganization&gt;
6                &lt;id root=&quot;123&quot; extension=&quot;92&quot;/&gt;
7                &lt;name&gt;some xyz&lt;/name&gt;
8                &lt;telecom use=&quot;WP&quot; value=&quot;tel:1234&quot;/&gt;
9                &lt;addr use=&quot;WP&quot;&gt;
10                  &lt;streetAddressLine&gt;address&lt;/streetAddressLine&gt;
11                  &lt;city&gt;city&lt;/city&gt;
12                  &lt;state&gt;state&lt;/state&gt;
13                  &lt;postalCode&gt;12345&lt;/postalCode&gt;
14                  &lt;country&gt;US&lt;/country&gt;
15                &lt;/addr&gt;
16              &lt;/representedCustodianOrganization&gt;
17            &lt;/assignedCustodian&gt;
18          &lt;/custodian&gt;
19    &lt;/ClinicalDocument&gt;
20

In this I need to read the CITY element under Custodian Tag.

ANSWER

Answered 2021-Dec-08 at 14:34

From 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.

Source https://stackoverflow.com/questions/70274991

QUESTION

How can I reorder an ELEMENT inside of an OBJECT of an array of OBJECTS NOT sort?

Asked 2021-Dec-01 at 22:10

Every 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: &quot;hi number 1a&quot;,
4     id: &quot;hi number 2a&quot;,
5     address: &quot;hi number 3a&quot;
6  },  {
7     name: &quot;hi number 1b&quot;,
8     id: &quot;hi number 2b&quot;,
9     address: &quot;hi number 3b&quot;
10  },  {
11     name: &quot;hi number 1c&quot;,
12     id: &quot;hi number 2c&quot;,
13     address: &quot;hi number 3c&quot;
14  },  {
15     name: &quot;hi number 1d&quot;,
16     id: &quot;hi number 2d&quot;,
17     address: &quot;hi number 3d&quot;
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: &quot;hi number 1a&quot;,
4     id: &quot;hi number 2a&quot;,
5     address: &quot;hi number 3a&quot;
6  },  {
7     name: &quot;hi number 1b&quot;,
8     id: &quot;hi number 2b&quot;,
9     address: &quot;hi number 3b&quot;
10  },  {
11     name: &quot;hi number 1c&quot;,
12     id: &quot;hi number 2c&quot;,
13     address: &quot;hi number 3c&quot;
14  },  {
15     name: &quot;hi number 1d&quot;,
16     id: &quot;hi number 2d&quot;,
17     address: &quot;hi number 3d&quot;
18  }
19]
20let obj = [
21  {
22     id: &quot;hi number 2a&quot;,
23     name: &quot;hi number 1a&quot;,
24     address: &quot;hi number 3a&quot;
25  },  {
26     id: &quot;hi number 2b&quot;,
27     name: &quot;hi number 1b&quot;,
28     address: &quot;hi number 3b&quot;
29  },  {
30     id: &quot;hi number 2c&quot;,
31     name: &quot;hi number 1c&quot;,
32     address: &quot;hi number 3c&quot;
33  },  {
34     id: &quot;hi number 2d&quot;,
35     name: &quot;hi number 1d&quot;,
36     address: &quot;hi number 3d&quot;
37  }
38]
39

Here's the code I've tried:

1let obj = [
2  {
3     name: &quot;hi number 1a&quot;,
4     id: &quot;hi number 2a&quot;,
5     address: &quot;hi number 3a&quot;
6  },  {
7     name: &quot;hi number 1b&quot;,
8     id: &quot;hi number 2b&quot;,
9     address: &quot;hi number 3b&quot;
10  },  {
11     name: &quot;hi number 1c&quot;,
12     id: &quot;hi number 2c&quot;,
13     address: &quot;hi number 3c&quot;
14  },  {
15     name: &quot;hi number 1d&quot;,
16     id: &quot;hi number 2d&quot;,
17     address: &quot;hi number 3d&quot;
18  }
19]
20let obj = [
21  {
22     id: &quot;hi number 2a&quot;,
23     name: &quot;hi number 1a&quot;,
24     address: &quot;hi number 3a&quot;
25  },  {
26     id: &quot;hi number 2b&quot;,
27     name: &quot;hi number 1b&quot;,
28     address: &quot;hi number 3b&quot;
29  },  {
30     id: &quot;hi number 2c&quot;,
31     name: &quot;hi number 1c&quot;,
32     address: &quot;hi number 3c&quot;
33  },  {
34     id: &quot;hi number 2d&quot;,
35     name: &quot;hi number 1d&quot;,
36     address: &quot;hi number 3d&quot;
37  }
38]
39        $scope.arraymove = (arr, fromindex, toindex) =&gt; {
40
41            let len = arr.length;
42            let newArr = [];
43            let resultArr = [];
44
45            for (let i = 0; i &lt; 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 &lt; 0) {
52                    old_index += len;
53                }
54                while (new_index &lt; 0) {
55                    new_index += len;
56                }
57                if (new_index &gt;= 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(&quot;NEW ARRAY: &quot;, thearr);
66                return thearr;
67            }
68
69            console.log(&quot;New Reordered ARRAY: &quot;, 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:08

Here you go, though be aware that object field order cannot be guaranteed.

1let obj = [
2  {
3     name: &quot;hi number 1a&quot;,
4     id: &quot;hi number 2a&quot;,
5     address: &quot;hi number 3a&quot;
6  },  {
7     name: &quot;hi number 1b&quot;,
8     id: &quot;hi number 2b&quot;,
9     address: &quot;hi number 3b&quot;
10  },  {
11     name: &quot;hi number 1c&quot;,
12     id: &quot;hi number 2c&quot;,
13     address: &quot;hi number 3c&quot;
14  },  {
15     name: &quot;hi number 1d&quot;,
16     id: &quot;hi number 2d&quot;,
17     address: &quot;hi number 3d&quot;
18  }
19]
20let obj = [
21  {
22     id: &quot;hi number 2a&quot;,
23     name: &quot;hi number 1a&quot;,
24     address: &quot;hi number 3a&quot;
25  },  {
26     id: &quot;hi number 2b&quot;,
27     name: &quot;hi number 1b&quot;,
28     address: &quot;hi number 3b&quot;
29  },  {
30     id: &quot;hi number 2c&quot;,
31     name: &quot;hi number 1c&quot;,
32     address: &quot;hi number 3c&quot;
33  },  {
34     id: &quot;hi number 2d&quot;,
35     name: &quot;hi number 1d&quot;,
36     address: &quot;hi number 3d&quot;
37  }
38]
39        $scope.arraymove = (arr, fromindex, toindex) =&gt; {
40
41            let len = arr.length;
42            let newArr = [];
43            let resultArr = [];
44
45            for (let i = 0; i &lt; 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 &lt; 0) {
52                    old_index += len;
53                }
54                while (new_index &lt; 0) {
55                    new_index += len;
56                }
57                if (new_index &gt;= 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(&quot;NEW ARRAY: &quot;, thearr);
66                return thearr;
67            }
68
69            console.log(&quot;New Reordered ARRAY: &quot;, 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 =&gt; ({id: o.id, name: o.name, address: o.address}));
92console.log(newobj)

Source https://stackoverflow.com/questions/70191581

QUESTION

how to normalize nested json in python

Asked 2021-Dec-01 at 17:17

i have a json file contains :

my expected resulted is to have comments and replies together in same row

1[
2  {
3    &quot;comments_full&quot;: [
4      {
5        &quot;comment_id&quot;: &quot;10158615203365493&quot;,
6        &quot;comment_url&quot;: &quot;https://facebook.com/10158615203365493&quot;,
7        &quot;commenter_id&quot;: &quot;100000738385184&quot;,
8        &quot;commenter_url&quot;: &quot;https://facebook.com/karencelli1978?fref=nf&amp;rc=p&amp;refid=52&amp;__tn__=R&quot;,
9        &quot;commenter_name&quot;: &quot;Karen Celli Gonin&quot;,
10        &quot;commenter_meta&quot;: null,
11        &quot;comment_text&quot;: &quot;Johnny, une institution, un pilier, un beau cadeau \ud83d\udc9e&quot;,
12        &quot;comment_time&quot;: 1637139809000,
13        &quot;comment_image&quot;: &quot;https://bytl.fr/DiagBbox?fbclid=IwAR1R7gYF4UcFAx1PmTMQSsjAU6uE2ktufl9MkeGfFXHjMbEgSVFzuLWu0Kk&quot;,
14        &quot;comment_reactors&quot;: [],
15        &quot;comment_reactions&quot;: null,
16        &quot;comment_reaction_count&quot;: null,
17        &quot;replies&quot;: [
18          {
19            &quot;comment_id&quot;: &quot;10158637221900493&quot;,
20            &quot;comment_url&quot;: &quot;https://facebook.com/10158637221900493&quot;,
21            &quot;commenter_id&quot;: &quot;94533530492&quot;,
22            &quot;commenter_url&quot;: &quot;https://facebook.com/bouyguestelecom/?rc=p&amp;refid=52&amp;__tn__=%7ERR&quot;,
23            &quot;commenter_name&quot;: &quot;Bouygues Telecom&quot;,
24            &quot;commenter_meta&quot;: &quot;Author&quot;,
25            &quot;comment_text&quot;: &quot;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&quot;,
26            &quot;comment_time&quot;: 1637971200000,
27            &quot;comment_image&quot;: &quot;https://bytl.fr/DiagBbox?fbclid=IwAR1R7gYF4UcFAx1PmTMQSsjAU6uE2ktufl9MkeGfFXHjMbEgSVFzuLWu0Kk&quot;,
28            &quot;comment_reactors&quot;: [],
29            &quot;comment_reactions&quot;: null,
30            &quot;comment_reaction_count&quot;: null
31          }, {
32        &quot;comment_id&quot;: &quot;387128923196835&quot;,
33        &quot;comment_url&quot;: &quot;https://facebook.com/387128923196835&quot;,
34        &quot;commenter_id&quot;: &quot;1603185710&quot;,
35        &quot;commenter_url&quot;: &quot;https://facebook.com/ju.cecchi?fref=nf&amp;rc=p&amp;refid=52&amp;__tn__=R&quot;,
36        &quot;commenter_name&quot;: &quot;Ju Cecchi&quot;,
37        &quot;commenter_meta&quot;: null,
38        &quot;comment_text&quot;: &quot;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 !&quot;,
39        &quot;comment_time&quot;: null,
40        &quot;comment_image&quot;: &quot;https://bytl.fr/MeteoDuReseau?fbclid=IwAR0i3VrTiHJp27OIjahy0J2D1tOSCJX5iC9_bMEk1BZ4F-s82hSDyNrz18A&quot;,
41        &quot;comment_reactors&quot;: [],
42        &quot;comment_reactions&quot;: null,
43        &quot;comment_reaction_count&quot;: null,
44        &quot;replies&quot;: [
45          {
46            &quot;comment_id&quot;: &quot;387132053196522&quot;,
47            &quot;comment_url&quot;: &quot;https://facebook.com/387132053196522&quot;,
48            &quot;commenter_id&quot;: &quot;94533530492&quot;,
49            &quot;commenter_url&quot;: &quot;https://facebook.com/bouyguestelecom/?rc=p&amp;refid=52&amp;__tn__=%7ERR&quot;,
50            &quot;commenter_name&quot;: &quot;Bouygues Telecom&quot;,
51            &quot;commenter_meta&quot;: null,
52            &quot;comment_text&quot;: &quot;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 \&quot;J'ai un probl\u00e8me r\u00e9seau\&quot;.\n\n\u00c0 bient\u00f4t,\n\u00c9milie, conseill\u00e8re Bouygues Telecom&quot;,
53            &quot;comment_time&quot;: null,
54            &quot;comment_image&quot;: &quot;https://bytl.fr/MeteoDuReseau?fbclid=IwAR0i3VrTiHJp27OIjahy0J2D1tOSCJX5iC9_bMEk1BZ4F-s82hSDyNrz18A&quot;,
55            &quot;comment_reactors&quot;: [],
56            &quot;comment_reactions&quot;: null,
57            &quot;comment_reaction_count&quot;: null
58          },
59          {
60            &quot;comment_id&quot;: &quot;387240859852308&quot;,
61            &quot;comment_url&quot;: &quot;https://facebook.com/387240859852308&quot;,
62            &quot;commenter_id&quot;: &quot;100001879469164&quot;,
63            &quot;commenter_url&quot;: &quot;https://facebook.com/bruno.venditti.1?fref=nf&amp;rc=p&amp;__tn__=R&quot;,
64            &quot;commenter_name&quot;: &quot;Bruno Venditti Altobelli&quot;,
65            &quot;commenter_meta&quot;: null,
66            &quot;comment_text&quot;: &quot;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.&quot;,
67            &quot;comment_time&quot;: null,
68            &quot;comment_image&quot;: null,
69            &quot;comment_reactors&quot;: [],
70            &quot;comment_reactions&quot;: null,
71            &quot;comment_reaction_count&quot;: null
72          }
73        ]
74      }
75    ]
76  }
77]
78

when i use :

1[
2  {
3    &quot;comments_full&quot;: [
4      {
5        &quot;comment_id&quot;: &quot;10158615203365493&quot;,
6        &quot;comment_url&quot;: &quot;https://facebook.com/10158615203365493&quot;,
7        &quot;commenter_id&quot;: &quot;100000738385184&quot;,
8        &quot;commenter_url&quot;: &quot;https://facebook.com/karencelli1978?fref=nf&amp;rc=p&amp;refid=52&amp;__tn__=R&quot;,
9        &quot;commenter_name&quot;: &quot;Karen Celli Gonin&quot;,
10        &quot;commenter_meta&quot;: null,
11        &quot;comment_text&quot;: &quot;Johnny, une institution, un pilier, un beau cadeau \ud83d\udc9e&quot;,
12        &quot;comment_time&quot;: 1637139809000,
13        &quot;comment_image&quot;: &quot;https://bytl.fr/DiagBbox?fbclid=IwAR1R7gYF4UcFAx1PmTMQSsjAU6uE2ktufl9MkeGfFXHjMbEgSVFzuLWu0Kk&quot;,
14        &quot;comment_reactors&quot;: [],
15        &quot;comment_reactions&quot;: null,
16        &quot;comment_reaction_count&quot;: null,
17        &quot;replies&quot;: [
18          {
19            &quot;comment_id&quot;: &quot;10158637221900493&quot;,
20            &quot;comment_url&quot;: &quot;https://facebook.com/10158637221900493&quot;,
21            &quot;commenter_id&quot;: &quot;94533530492&quot;,
22            &quot;commenter_url&quot;: &quot;https://facebook.com/bouyguestelecom/?rc=p&amp;refid=52&amp;__tn__=%7ERR&quot;,
23            &quot;commenter_name&quot;: &quot;Bouygues Telecom&quot;,
24            &quot;commenter_meta&quot;: &quot;Author&quot;,
25            &quot;comment_text&quot;: &quot;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&quot;,
26            &quot;comment_time&quot;: 1637971200000,
27            &quot;comment_image&quot;: &quot;https://bytl.fr/DiagBbox?fbclid=IwAR1R7gYF4UcFAx1PmTMQSsjAU6uE2ktufl9MkeGfFXHjMbEgSVFzuLWu0Kk&quot;,
28            &quot;comment_reactors&quot;: [],
29            &quot;comment_reactions&quot;: null,
30            &quot;comment_reaction_count&quot;: null
31          }, {
32        &quot;comment_id&quot;: &quot;387128923196835&quot;,
33        &quot;comment_url&quot;: &quot;https://facebook.com/387128923196835&quot;,
34        &quot;commenter_id&quot;: &quot;1603185710&quot;,
35        &quot;commenter_url&quot;: &quot;https://facebook.com/ju.cecchi?fref=nf&amp;rc=p&amp;refid=52&amp;__tn__=R&quot;,
36        &quot;commenter_name&quot;: &quot;Ju Cecchi&quot;,
37        &quot;commenter_meta&quot;: null,
38        &quot;comment_text&quot;: &quot;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 !&quot;,
39        &quot;comment_time&quot;: null,
40        &quot;comment_image&quot;: &quot;https://bytl.fr/MeteoDuReseau?fbclid=IwAR0i3VrTiHJp27OIjahy0J2D1tOSCJX5iC9_bMEk1BZ4F-s82hSDyNrz18A&quot;,
41        &quot;comment_reactors&quot;: [],
42        &quot;comment_reactions&quot;: null,
43        &quot;comment_reaction_count&quot;: null,
44        &quot;replies&quot;: [
45          {
46            &quot;comment_id&quot;: &quot;387132053196522&quot;,
47            &quot;comment_url&quot;: &quot;https://facebook.com/387132053196522&quot;,
48            &quot;commenter_id&quot;: &quot;94533530492&quot;,
49            &quot;commenter_url&quot;: &quot;https://facebook.com/bouyguestelecom/?rc=p&amp;refid=52&amp;__tn__=%7ERR&quot;,
50            &quot;commenter_name&quot;: &quot;Bouygues Telecom&quot;,
51            &quot;commenter_meta&quot;: null,
52            &quot;comment_text&quot;: &quot;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 \&quot;J'ai un probl\u00e8me r\u00e9seau\&quot;.\n\n\u00c0 bient\u00f4t,\n\u00c9milie, conseill\u00e8re Bouygues Telecom&quot;,
53            &quot;comment_time&quot;: null,
54            &quot;comment_image&quot;: &quot;https://bytl.fr/MeteoDuReseau?fbclid=IwAR0i3VrTiHJp27OIjahy0J2D1tOSCJX5iC9_bMEk1BZ4F-s82hSDyNrz18A&quot;,
55            &quot;comment_reactors&quot;: [],
56            &quot;comment_reactions&quot;: null,
57            &quot;comment_reaction_count&quot;: null
58          },
59          {
60            &quot;comment_id&quot;: &quot;387240859852308&quot;,
61            &quot;comment_url&quot;: &quot;https://facebook.com/387240859852308&quot;,
62            &quot;commenter_id&quot;: &quot;100001879469164&quot;,
63            &quot;commenter_url&quot;: &quot;https://facebook.com/bruno.venditti.1?fref=nf&amp;rc=p&amp;__tn__=R&quot;,
64            &quot;commenter_name&quot;: &quot;Bruno Venditti Altobelli&quot;,
65            &quot;commenter_meta&quot;: null,
66            &quot;comment_text&quot;: &quot;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.&quot;,
67            &quot;comment_time&quot;: null,
68            &quot;comment_image&quot;: null,
69            &quot;comment_reactors&quot;: [],
70            &quot;comment_reactions&quot;: null,
71            &quot;comment_reaction_count&quot;: 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    &quot;comments_full&quot;: [
4      {
5        &quot;comment_id&quot;: &quot;10158615203365493&quot;,
6        &quot;comment_url&quot;: &quot;https://facebook.com/10158615203365493&quot;,
7        &quot;commenter_id&quot;: &quot;100000738385184&quot;,
8        &quot;commenter_url&quot;: &quot;https://facebook.com/karencelli1978?fref=nf&amp;rc=p&amp;refid=52&amp;__tn__=R&quot;,
9        &quot;commenter_name&quot;: &quot;Karen Celli Gonin&quot;,
10        &quot;commenter_meta&quot;: null,
11        &quot;comment_text&quot;: &quot;Johnny, une institution, un pilier, un beau cadeau \ud83d\udc9e&quot;,
12        &quot;comment_time&quot;: 1637139809000,
13        &quot;comment_image&quot;: &quot;https://bytl.fr/DiagBbox?fbclid=IwAR1R7gYF4UcFAx1PmTMQSsjAU6uE2ktufl9MkeGfFXHjMbEgSVFzuLWu0Kk&quot;,
14        &quot;comment_reactors&quot;: [],
15        &quot;comment_reactions&quot;: null,
16        &quot;comment_reaction_count&quot;: null,
17        &quot;replies&quot;: [
18          {
19            &quot;comment_id&quot;: &quot;10158637221900493&quot;,
20            &quot;comment_url&quot;: &quot;https://facebook.com/10158637221900493&quot;,
21            &quot;commenter_id&quot;: &quot;94533530492&quot;,
22            &quot;commenter_url&quot;: &quot;https://facebook.com/bouyguestelecom/?rc=p&amp;refid=52&amp;__tn__=%7ERR&quot;,
23            &quot;commenter_name&quot;: &quot;Bouygues Telecom&quot;,
24            &quot;commenter_meta&quot;: &quot;Author&quot;,
25            &quot;comment_text&quot;: &quot;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&quot;,
26            &quot;comment_time&quot;: 1637971200000,
27            &quot;comment_image&quot;: &quot;https://bytl.fr/DiagBbox?fbclid=IwAR1R7gYF4UcFAx1PmTMQSsjAU6uE2ktufl9MkeGfFXHjMbEgSVFzuLWu0Kk&quot;,
28            &quot;comment_reactors&quot;: [],
29            &quot;comment_reactions&quot;: null,
30            &quot;comment_reaction_count&quot;: null
31          }, {
32        &quot;comment_id&quot;: &quot;387128923196835&quot;,
33        &quot;comment_url&quot;: &quot;https://facebook.com/387128923196835&quot;,
34        &quot;commenter_id&quot;: &quot;1603185710&quot;,
35        &quot;commenter_url&quot;: &quot;https://facebook.com/ju.cecchi?fref=nf&amp;rc=p&amp;refid=52&amp;__tn__=R&quot;,
36        &quot;commenter_name&quot;: &quot;Ju Cecchi&quot;,
37        &quot;commenter_meta&quot;: null,
38        &quot;comment_text&quot;: &quot;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 !&quot;,
39        &quot;comment_time&quot;: null,
40        &quot;comment_image&quot;: &quot;https://bytl.fr/MeteoDuReseau?fbclid=IwAR0i3VrTiHJp27OIjahy0J2D1tOSCJX5iC9_bMEk1BZ4F-s82hSDyNrz18A&quot;,
41        &quot;comment_reactors&quot;: [],
42        &quot;comment_reactions&quot;: null,
43        &quot;comment_reaction_count&quot;: null,
44        &quot;replies&quot;: [
45          {
46            &quot;comment_id&quot;: &quot;387132053196522&quot;,
47            &quot;comment_url&quot;: &quot;https://facebook.com/387132053196522&quot;,
48            &quot;commenter_id&quot;: &quot;94533530492&quot;,
49            &quot;commenter_url&quot;: &quot;https://facebook.com/bouyguestelecom/?rc=p&amp;refid=52&amp;__tn__=%7ERR&quot;,
50            &quot;commenter_name&quot;: &quot;Bouygues Telecom&quot;,
51            &quot;commenter_meta&quot;: null,
52            &quot;comment_text&quot;: &quot;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 \&quot;J'ai un probl\u00e8me r\u00e9seau\&quot;.\n\n\u00c0 bient\u00f4t,\n\u00c9milie, conseill\u00e8re Bouygues Telecom&quot;,
53            &quot;comment_time&quot;: null,
54            &quot;comment_image&quot;: &quot;https://bytl.fr/MeteoDuReseau?fbclid=IwAR0i3VrTiHJp27OIjahy0J2D1tOSCJX5iC9_bMEk1BZ4F-s82hSDyNrz18A&quot;,
55            &quot;comment_reactors&quot;: [],
56            &quot;comment_reactions&quot;: null,
57            &quot;comment_reaction_count&quot;: null
58          },
59          {
60            &quot;comment_id&quot;: &quot;387240859852308&quot;,
61            &quot;comment_url&quot;: &quot;https://facebook.com/387240859852308&quot;,
62            &quot;commenter_id&quot;: &quot;100001879469164&quot;,
63            &quot;commenter_url&quot;: &quot;https://facebook.com/bruno.venditti.1?fref=nf&amp;rc=p&amp;__tn__=R&quot;,
64            &quot;commenter_name&quot;: &quot;Bruno Venditti Altobelli&quot;,
65            &quot;commenter_meta&quot;: null,
66            &quot;comment_text&quot;: &quot;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.&quot;,
67            &quot;comment_time&quot;: null,
68            &quot;comment_image&quot;: null,
69            &quot;comment_reactors&quot;: [],
70            &quot;comment_reactions&quot;: null,
71            &quot;comment_reaction_count&quot;: 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    &quot;comments_full&quot;: [
4      {
5        &quot;comment_id&quot;: &quot;10158615203365493&quot;,
6        &quot;comment_url&quot;: &quot;https://facebook.com/10158615203365493&quot;,
7        &quot;commenter_id&quot;: &quot;100000738385184&quot;,
8        &quot;commenter_url&quot;: &quot;https://facebook.com/karencelli1978?fref=nf&amp;rc=p&amp;refid=52&amp;__tn__=R&quot;,
9        &quot;commenter_name&quot;: &quot;Karen Celli Gonin&quot;,
10        &quot;commenter_meta&quot;: null,
11        &quot;comment_text&quot;: &quot;Johnny, une institution, un pilier, un beau cadeau \ud83d\udc9e&quot;,
12        &quot;comment_time&quot;: 1637139809000,
13        &quot;comment_image&quot;: &quot;https://bytl.fr/DiagBbox?fbclid=IwAR1R7gYF4UcFAx1PmTMQSsjAU6uE2ktufl9MkeGfFXHjMbEgSVFzuLWu0Kk&quot;,
14        &quot;comment_reactors&quot;: [],
15        &quot;comment_reactions&quot;: null,
16        &quot;comment_reaction_count&quot;: null,
17        &quot;replies&quot;: [
18          {
19            &quot;comment_id&quot;: &quot;10158637221900493&quot;,
20            &quot;comment_url&quot;: &quot;https://facebook.com/10158637221900493&quot;,
21            &quot;commenter_id&quot;: &quot;94533530492&quot;,
22            &quot;commenter_url&quot;: &quot;https://facebook.com/bouyguestelecom/?rc=p&amp;refid=52&amp;__tn__=%7ERR&quot;,
23            &quot;commenter_name&quot;: &quot;Bouygues Telecom&quot;,
24            &quot;commenter_meta&quot;: &quot;Author&quot;,
25            &quot;comment_text&quot;: &quot;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&quot;,
26            &quot;comment_time&quot;: 1637971200000,
27            &quot;comment_image&quot;: &quot;https://bytl.fr/DiagBbox?fbclid=IwAR1R7gYF4UcFAx1PmTMQSsjAU6uE2ktufl9MkeGfFXHjMbEgSVFzuLWu0Kk&quot;,
28            &quot;comment_reactors&quot;: [],
29            &quot;comment_reactions&quot;: null,
30            &quot;comment_reaction_count&quot;: null
31          }, {
32        &quot;comment_id&quot;: &quot;387128923196835&quot;,
33        &quot;comment_url&quot;: &quot;https://facebook.com/387128923196835&quot;,
34        &quot;commenter_id&quot;: &quot;1603185710&quot;,
35        &quot;commenter_url&quot;: &quot;https://facebook.com/ju.cecchi?fref=nf&amp;rc=p&amp;refid=52&amp;__tn__=R&quot;,
36        &quot;commenter_name&quot;: &quot;Ju Cecchi&quot;,
37        &quot;commenter_meta&quot;: null,
38        &quot;comment_text&quot;: &quot;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 !&quot;,
39        &quot;comment_time&quot;: null,
40        &quot;comment_image&quot;: &quot;https://bytl.fr/MeteoDuReseau?fbclid=IwAR0i3VrTiHJp27OIjahy0J2D1tOSCJX5iC9_bMEk1BZ4F-s82hSDyNrz18A&quot;,
41        &quot;comment_reactors&quot;: [],
42        &quot;comment_reactions&quot;: null,
43        &quot;comment_reaction_count&quot;: null,
44        &quot;replies&quot;: [
45          {
46            &quot;comment_id&quot;: &quot;387132053196522&quot;,
47            &quot;comment_url&quot;: &quot;https://facebook.com/387132053196522&quot;,
48            &quot;commenter_id&quot;: &quot;94533530492&quot;,
49            &quot;commenter_url&quot;: &quot;https://facebook.com/bouyguestelecom/?rc=p&amp;refid=52&amp;__tn__=%7ERR&quot;,
50            &quot;commenter_name&quot;: &quot;Bouygues Telecom&quot;,
51            &quot;commenter_meta&quot;: null,
52            &quot;comment_text&quot;: &quot;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 \&quot;J'ai un probl\u00e8me r\u00e9seau\&quot;.\n\n\u00c0 bient\u00f4t,\n\u00c9milie, conseill\u00e8re Bouygues Telecom&quot;,
53            &quot;comment_time&quot;: null,
54            &quot;comment_image&quot;: &quot;https://bytl.fr/MeteoDuReseau?fbclid=IwAR0i3VrTiHJp27OIjahy0J2D1tOSCJX5iC9_bMEk1BZ4F-s82hSDyNrz18A&quot;,
55            &quot;comment_reactors&quot;: [],
56            &quot;comment_reactions&quot;: null,
57            &quot;comment_reaction_count&quot;: null
58          },
59          {
60            &quot;comment_id&quot;: &quot;387240859852308&quot;,
61            &quot;comment_url&quot;: &quot;https://facebook.com/387240859852308&quot;,
62            &quot;commenter_id&quot;: &quot;100001879469164&quot;,
63            &quot;commenter_url&quot;: &quot;https://facebook.com/bruno.venditti.1?fref=nf&amp;rc=p&amp;__tn__=R&quot;,
64            &quot;commenter_name&quot;: &quot;Bruno Venditti Altobelli&quot;,
65            &quot;commenter_meta&quot;: null,
66            &quot;comment_text&quot;: &quot;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.&quot;,
67            &quot;comment_time&quot;: null,
68            &quot;comment_image&quot;: null,
69            &quot;comment_reactors&quot;: [],
70            &quot;comment_reactions&quot;: null,
71            &quot;comment_reaction_count&quot;: 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    &quot;comments_full&quot;: [
4      {
5        &quot;comment_id&quot;: &quot;10158615203365493&quot;,
6        &quot;comment_url&quot;: &quot;https://facebook.com/10158615203365493&quot;,
7        &quot;commenter_id&quot;: &quot;100000738385184&quot;,
8        &quot;commenter_url&quot;: &quot;https://facebook.com/karencelli1978?fref=nf&amp;rc=p&amp;refid=52&amp;__tn__=R&quot;,
9        &quot;commenter_name&quot;: &quot;Karen Celli Gonin&quot;,
10        &quot;commenter_meta&quot;: null,
11        &quot;comment_text&quot;: &quot;Johnny, une institution, un pilier, un beau cadeau \ud83d\udc9e&quot;,
12        &quot;comment_time&quot;: 1637139809000,
13        &quot;comment_image&quot;: &quot;https://bytl.fr/DiagBbox?fbclid=IwAR1R7gYF4UcFAx1PmTMQSsjAU6uE2ktufl9MkeGfFXHjMbEgSVFzuLWu0Kk&quot;,
14        &quot;comment_reactors&quot;: [],
15        &quot;comment_reactions&quot;: null,
16        &quot;comment_reaction_count&quot;: null,
17        &quot;replies&quot;: [
18          {
19            &quot;comment_id&quot;: &quot;10158637221900493&quot;,
20            &quot;comment_url&quot;: &quot;https://facebook.com/10158637221900493&quot;,
21            &quot;commenter_id&quot;: &quot;94533530492&quot;,
22            &quot;commenter_url&quot;: &quot;https://facebook.com/bouyguestelecom/?rc=p&amp;refid=52&amp;__tn__=%7ERR&quot;,
23            &quot;commenter_name&quot;: &quot;Bouygues Telecom&quot;,
24            &quot;commenter_meta&quot;: &quot;Author&quot;,
25            &quot;comment_text&quot;: &quot;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&quot;,
26            &quot;comment_time&quot;: 1637971200000,
27            &quot;comment_image&quot;: &quot;https://bytl.fr/DiagBbox?fbclid=IwAR1R7gYF4UcFAx1PmTMQSsjAU6uE2ktufl9MkeGfFXHjMbEgSVFzuLWu0Kk&quot;,
28            &quot;comment_reactors&quot;: [],
29            &quot;comment_reactions&quot;: null,
30            &quot;comment_reaction_count&quot;: null
31          }, {
32        &quot;comment_id&quot;: &quot;387128923196835&quot;,
33        &quot;comment_url&quot;: &quot;https://facebook.com/387128923196835&quot;,
34        &quot;commenter_id&quot;: &quot;1603185710&quot;,
35        &quot;commenter_url&quot;: &quot;https://facebook.com/ju.cecchi?fref=nf&amp;rc=p&amp;refid=52&amp;__tn__=R&quot;,
36        &quot;commenter_name&quot;: &quot;Ju Cecchi&quot;,
37        &quot;commenter_meta&quot;: null,
38        &quot;comment_text&quot;: &quot;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 !&quot;,
39        &quot;comment_time&quot;: null,
40        &quot;comment_image&quot;: &quot;https://bytl.fr/MeteoDuReseau?fbclid=IwAR0i3VrTiHJp27OIjahy0J2D1tOSCJX5iC9_bMEk1BZ4F-s82hSDyNrz18A&quot;,
41        &quot;comment_reactors&quot;: [],
42        &quot;comment_reactions&quot;: null,
43        &quot;comment_reaction_count&quot;: null,
44        &quot;replies&quot;: [
45          {
46            &quot;comment_id&quot;: &quot;387132053196522&quot;,
47            &quot;comment_url&quot;: &quot;https://facebook.com/387132053196522&quot;,
48            &quot;commenter_id&quot;: &quot;94533530492&quot;,
49            &quot;commenter_url&quot;: &quot;https://facebook.com/bouyguestelecom/?rc=p&amp;refid=52&amp;__tn__=%7ERR&quot;,
50            &quot;commenter_name&quot;: &quot;Bouygues Telecom&quot;,
51            &quot;commenter_meta&quot;: null,
52            &quot;comment_text&quot;: &quot;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 \&quot;J'ai un probl\u00e8me r\u00e9seau\&quot;.\n\n\u00c0 bient\u00f4t,\n\u00c9milie, conseill\u00e8re Bouygues Telecom&quot;,
53            &quot;comment_time&quot;: null,
54            &quot;comment_image&quot;: &quot;https://bytl.fr/MeteoDuReseau?fbclid=IwAR0i3VrTiHJp27OIjahy0J2D1tOSCJX5iC9_bMEk1BZ4F-s82hSDyNrz18A&quot;,
55            &quot;comment_reactors&quot;: [],
56            &quot;comment_reactions&quot;: null,
57            &quot;comment_reaction_count&quot;: null
58          },
59          {
60            &quot;comment_id&quot;: &quot;387240859852308&quot;,
61            &quot;comment_url&quot;: &quot;https://facebook.com/387240859852308&quot;,
62            &quot;commenter_id&quot;: &quot;100001879469164&quot;,
63            &quot;commenter_url&quot;: &quot;https://facebook.com/bruno.venditti.1?fref=nf&amp;rc=p&amp;__tn__=R&quot;,
64            &quot;commenter_name&quot;: &quot;Bruno Venditti Altobelli&quot;,
65            &quot;commenter_meta&quot;: null,
66            &quot;comment_text&quot;: &quot;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.&quot;,
67            &quot;comment_time&quot;: null,
68            &quot;comment_image&quot;: null,
69            &quot;comment_reactors&quot;: [],
70            &quot;comment_reactions&quot;: null,
71            &quot;comment_reaction_count&quot;: 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:17

Try:

  1. json_normalize on "comments_full"
  2. explode the replies column to get one reply per row
  3. json_normalize on "replies" and add_prefix to differentiate from comments columns
  4. join to get the output
1[
2  {
3    &quot;comments_full&quot;: [
4      {
5        &quot;comment_id&quot;: &quot;10158615203365493&quot;,
6        &quot;comment_url&quot;: &quot;https://facebook.com/10158615203365493&quot;,
7        &quot;commenter_id&quot;: &quot;100000738385184&quot;,
8        &quot;commenter_url&quot;: &quot;https://facebook.com/karencelli1978?fref=nf&amp;rc=p&amp;refid=52&amp;__tn__=R&quot;,
9        &quot;commenter_name&quot;: &quot;Karen Celli Gonin&quot;,
10        &quot;commenter_meta&quot;: null,
11        &quot;comment_text&quot;: &quot;Johnny, une institution, un pilier, un beau cadeau \ud83d\udc9e&quot;,
12        &quot;comment_time&quot;: 1637139809000,
13        &quot;comment_image&quot;: &quot;https://bytl.fr/DiagBbox?fbclid=IwAR1R7gYF4UcFAx1PmTMQSsjAU6uE2ktufl9MkeGfFXHjMbEgSVFzuLWu0Kk&quot;,
14        &quot;comment_reactors&quot;: [],
15        &quot;comment_reactions&quot;: null,
16        &quot;comment_reaction_count&quot;: null,
17        &quot;replies&quot;: [
18          {
19            &quot;comment_id&quot;: &quot;10158637221900493&quot;,
20            &quot;comment_url&quot;: &quot;https://facebook.com/10158637221900493&quot;,
21            &quot;commenter_id&quot;: &quot;94533530492&quot;,
22            &quot;commenter_url&quot;: &quot;https://facebook.com/bouyguestelecom/?rc=p&amp;refid=52&amp;__tn__=%7ERR&quot;,
23            &quot;commenter_name&quot;: &quot;Bouygues Telecom&quot;,
24            &quot;commenter_meta&quot;: &quot;Author&quot;,
25            &quot;comment_text&quot;: &quot;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&quot;,
26            &quot;comment_time&quot;: 1637971200000,
27            &quot;comment_image&quot;: &quot;https://bytl.fr/DiagBbox?fbclid=IwAR1R7gYF4UcFAx1PmTMQSsjAU6uE2ktufl9MkeGfFXHjMbEgSVFzuLWu0Kk&quot;,
28            &quot;comment_reactors&quot;: [],
29            &quot;comment_reactions&quot;: null,
30            &quot;comment_reaction_count&quot;: null
31          }, {
32        &quot;comment_id&quot;: &quot;387128923196835&quot;,
33        &quot;comment_url&quot;: &quot;https://facebook.com/387128923196835&quot;,
34        &quot;commenter_id&quot;: &quot;1603185710&quot;,
35        &quot;commenter_url&quot;: &quot;https://facebook.com/ju.cecchi?fref=nf&amp;rc=p&amp;refid=52&amp;__tn__=R&quot;,
36        &quot;commenter_name&quot;: &quot;Ju Cecchi&quot;,
37        &quot;commenter_meta&quot;: null,
38        &quot;comment_text&quot;: &quot;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 !&quot;,
39        &quot;comment_time&quot;: null,
40        &quot;comment_image&quot;: &quot;https://bytl.fr/MeteoDuReseau?fbclid=IwAR0i3VrTiHJp27OIjahy0J2D1tOSCJX5iC9_bMEk1BZ4F-s82hSDyNrz18A&quot;,
41        &quot;comment_reactors&quot;: [],
42        &quot;comment_reactions&quot;: null,
43        &quot;comment_reaction_count&quot;: null,
44        &quot;replies&quot;: [
45          {
46            &quot;comment_id&quot;: &quot;387132053196522&quot;,
47            &quot;comment_url&quot;: &quot;https://facebook.com/387132053196522&quot;,
48            &quot;commenter_id&quot;: &quot;94533530492&quot;,
49            &quot;commenter_url&quot;: &quot;https://facebook.com/bouyguestelecom/?rc=p&amp;refid=52&amp;__tn__=%7ERR&quot;,
50            &quot;commenter_name&quot;: &quot;Bouygues Telecom&quot;,
51            &quot;commenter_meta&quot;: null,
52            &quot;comment_text&quot;: &quot;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 \&quot;J'ai un probl\u00e8me r\u00e9seau\&quot;.\n\n\u00c0 bient\u00f4t,\n\u00c9milie, conseill\u00e8re Bouygues Telecom&quot;,
53            &quot;comment_time&quot;: null,
54            &quot;comment_image&quot;: &quot;https://bytl.fr/MeteoDuReseau?fbclid=IwAR0i3VrTiHJp27OIjahy0J2D1tOSCJX5iC9_bMEk1BZ4F-s82hSDyNrz18A&quot;,
55            &quot;comment_reactors&quot;: [],
56            &quot;comment_reactions&quot;: null,
57            &quot;comment_reaction_count&quot;: null
58          },
59          {
60            &quot;comment_id&quot;: &quot;387240859852308&quot;,
61            &quot;comment_url&quot;: &quot;https://facebook.com/387240859852308&quot;,
62            &quot;commenter_id&quot;: &quot;100001879469164&quot;,
63            &quot;commenter_url&quot;: &quot;https://facebook.com/bruno.venditti.1?fref=nf&amp;rc=p&amp;__tn__=R&quot;,
64            &quot;commenter_name&quot;: &quot;Bruno Venditti Altobelli&quot;,
65            &quot;commenter_meta&quot;: null,
66            &quot;comment_text&quot;: &quot;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.&quot;,
67            &quot;comment_time&quot;: null,
68            &quot;comment_image&quot;: null,
69            &quot;comment_reactors&quot;: [],
70            &quot;comment_reactions&quot;: null,
71            &quot;comment_reaction_count&quot;: 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(&quot;replies&quot;).reset_index(drop=True)
94replies = pd.json_normalize(comments[&quot;replies&quot;].tolist()).add_prefix(&quot;reply.&quot;)
95output = comments.join(replies)
96

Source https://stackoverflow.com/questions/70187872

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

Share this Page

share link

Get latest updates on Telecom