kindjacket kindjacket - 1 year ago 90
JSON Question

SQL developer export cuts data in cell short when exporting WKT

I'm using pl sql and sql developer (mac). I'm trying to export a sdo geometry by converting it to WKT (using

). The problem is that when use the export function in sql (right clicking the query result then clicking export) if I export the result as either a json or csv. The text that describes the WKT is cut short.

I believe this is a problem with the export function and not the data as when I copy the data from the cell to my clipboard and paste it, it looks fine.

The export function maxes out at 4000 characters and the desired string is 9707 characters long.

Is there any way to fix this export issue?

Answer Source

To solve this I've exported the file as an XML from SQL Developer (right click query result and click export).

To turn the XML into a CSV I then ran the following python script

    import xml.etree.ElementTree as ET
    import pandas as pd

    tree = ET.parse('query_output.xml')
    root = tree.getroot()

    output = []
    for row in root.findall('ROW'):
        insert = {}
        for element in row:
            result = element.attrib['NAME']  ### Column Name
            insert[result] = element.text  ### Data

    result = pd.DataFrame.from_dict(output)
    result.to_csv('query_output.csv', index = False)