1

I tried using a name that more accurately describes my question but msg said I am limited to 150 chars.

Looking for assistance from someone who has advanced SQL skills. Ideally I want to do it in SQL to let the computer do the work. Too much manual manipulation is ripe with the possibility of mistakes. I've already searched for users groups within Google. All emails are being returned saying the email does not exist anymore. What I am using appears to be a proprietary version of Dremel SQL / Google SQL, however, someone experienced in Dremel SQL will probably be able to guide me in the right direction.

BACKGROUND INFO:

  • Pulling a column that is an array column which holds another array (a notes column). I think maybe an array of arrays?
  • I have not figured a way to do what I am trying to do with Google or Dremel SQL yet.
  • So for now, I am doing it the hard way.
  • As originally pulled, the data looks like this [{Array of arrays}, {Array of arrays}, {Array of arrays}, etc., repeat... : More specifically: [{4 or more text fields which could also hold numbers and separated by commas}, {another set of fields}, {another set of fields}...]

I.E. (this is all in just one column of data and hundreds of rows)

[
    {"created":"1540236216969","notes": blah... blah... blah", "original_text_length":534, "User_email":"someone@emailaddress.com","user_shortname":"someone"},
    {"created":"1540236216969","notes": blah... blah... blah", "original_text_length":1224, "User_email":"someone@emailaddress.com","user_shortname":"someone"},
    {"created":"1540236216969","notes": blah... blah... blah", "original_text_length":1664, "User_email":"someone@emailaddress.com","user_shortname":"someone"}
    ...
]

The number of these is different for each row pulled and each has a specific ID # A typical row of data is: ID #, start_date, end_date, some other fields, notes_(the array field)

WHAT I AM DOING NOW is:

  1. SQL data pull,
  2. exporting to google sheets,
  3. make separate tabs for the different array columns.
  4. copying the notes column (the array column holding arrays) to a separate tab on Google Sheets, then
  5. Split Text To Columns using the first curly brace "{" as the separater.

Here is where my dillema is. Once pulled, I need to split all of those columns again to separate each of the individual elements in each array. Unable to Split text to Columns again with all of them highlighted. I can Split Text to Columns again one at a time but will really be a pain if I have to do that individually for each column and every row (hundreds of rows). Need to find a way to automate this.

I will also need to change each of unix dates to calendar dates within each array PLUS add rows to the spreadsheet depending on the number of columns from the first split. The columns are different for each row depending on how many notes have been added.

OR... do it with SQL (which appears to be a proprietary type of SQL similar to NoSQL but not the same). I have tried using syntax's for IBM SQL, Oracle SQL, SQL Server, and others found online but none work.

OR... do it with a looping function within Google Sheets.

Possibly re-add it to the database as a new table once both sets of arrays are completely split up.

END RESULT ID#, date1, date 2, first created date (right now a unix date), first note, first other field, etc...

Then add a new row with Same ID# from above, date1 from row above, date 2 from row above, next (2nd) created date (right now a unix date), 2nd note, 2nd other field, etc...

Add a new row... 3rd set of notes etc.

Andrea
  • 11,801
  • 17
  • 65
  • 72
Rick P
  • 55
  • 10
  • Seems you got JSON data, no need to reinvent the wheel: https://en.wikipedia.org/wiki/JSON – dnoeth Jan 13 '19 at 16:16
  • Not sure how the columns are populated. They could be JSON I suppose. I made a spreadsheet to further explain what I need to do. Link is below. I cannot load software. I need to do it using either SQL or doing it in Google Sheets. Link to the Gogle Sheet - https://docs.google.com/spreadsheets/d/1NHX0nWDsS4SHJB74T9CVzNf3ECbl8qaQ_Vk5kdof5m8/edit?usp=sharing – Rick P Jan 14 '19 at 02:50
  • Seems Google's Standard SQL supports at least some basic JSON functionality: https://cloud.google.com/bigquery/docs/reference/standard-sql/json_functions , e.g. `JSON_EXTRACT_SCALAR(mycol,'$.[1].created')` – dnoeth Jan 14 '19 at 19:36
  • I'll give it a try. Thank you much. – Rick P Jan 18 '19 at 01:39

0 Answers0