I am trying to create a table into BigQuery by importing a file. In that file the date-time format is like this 4/12/2016 12:00:00 AM. BigQuery is not creating a table because of AM. To change that format I tried spreadsheet but it couldn't handle it because the dataset is large. What other options do I have so that I can import that data into BigQuery.
Converting date-time format for large dataset
230 views Asked by siddhesh daphane At
2
There are 2 answers
0
Anjela B
On
Expounding on Jiho Choi's answer, you can use the following sample code from this GCP Documentation; this loads a CSV file from Cloud Storage using an explicit schema, hence you can explicitly define your column as string:
from google.cloud import bigquery
# Construct a BigQuery client object.
client = bigquery.Client()
# TODO(developer): Set table_id to the ID of the table to create.
table_id = "your-project.your_dataset.your_table_name"
job_config = bigquery.LoadJobConfig(
schema=[
bigquery.SchemaField("id", "STRING"),
bigquery.SchemaField("time", "STRING"),
],
skip_leading_rows=1,
# The source format defaults to CSV, so the line below is optional.
source_format=bigquery.SourceFormat.CSV,
)
uri = "gs://my-bucket/20220602.csv"
load_job = client.load_table_from_uri(
uri, table_id, job_config=job_config
) # Make an API request.
load_job.result() # Waits for the job to complete.
destination_table = client.get_table(table_id) # Make an API request.
print("Loaded {} rows.".format(destination_table.num_rows))
20220602.csv:
Loaded in Bigquery:
Then apply the PARSE_DATETIME() function when querying as previously stated.
Related Questions in SQL
- SQL schema for a fill-in-the-blank exercise
- Hibernate: JOIN inheritance question - why the need for two left joins
- What's supposed to be the problem in this query?
- Compare fields in two tables
- How to change woocomerce or full wordpress currency with value from USD to AUD
- Dynamic query creation with Array like implementation
- SQL query to get student enrolled in this month in a course - Moodle
- SQL LAG() function returning 0 for every row despite available previous rows
- Convert C# DateTime.Ticks to Bigquery DateTime Format
- Use row values from another table to select them as columns and establish relations between them (pivot table)
- SQL: Generate combination table based on source and destination column from same table
- how to use system's environnement variables in sql script
- PHP fetchAll on JOIN
- Multitable joining in Sql
- How to display name starting from 'z' by using BETWEEN cmd only?
Related Questions in GOOGLE-BIGQUERY
- SQL LAG() function returning 0 for every row despite available previous rows
- Convert C# DateTime.Ticks to Bigquery DateTime Format
- SELECT AS STRUCT/VALUES
- Google Datastream errors on larger MySQL tables
- Can i add new label called looker-context-look_id in BigQuery connection(Looker)
- BigQuery external table using JSON files
- Does Apache Beam's BigQuery IO Support JSON Datatype Fields for Streaming Inserts?
- sample query for review for improvement on big query
- How does Big Query differentiate between a day and month when we upload any CSV or text file?
- How to get max value of a column when ids are unique but they are related through different variables
- how to do a filter from a table where 2 different columns has 2 different records which has same set of key combinations in bigquery?
- How to return a string that has a special character - BigQuery
- How do I merge multiple tables into a new table in BigQuery?
- Customer Churn Calculation
- Is it correct to add "UNNEST" in the "ON" condition of a (left) join?
Related Questions in DATA-ANALYSIS
- Pneumonia detection, using transfer learning
- duplicates within a 30 day period in samples from location A
- Understanding numeric_only boolean parameter in Pandas
- How can I turn categories into columns with percentage results?
- Unable to filter in power bi dax query
- YTD sum by month, using only latest value for each month
- Stopping a Power BI Table visual slicing the result of a virtual table
- Removing duplicate data conditionally in Excel
- How can I compare the similarity between multiple sets?
- Forecast the revenue for next month using 1 year historical data
- issue using dataset with data analysis project
- How can passive terms be rendered in the calculation of an MFA in R?
- Upsert using DuckDB
- Dynamic Filtering of Calculated Table Not Working with SELECTEDVALUE(slicer) in Power BI
- Mediation Analysis in R with two mediators in a repeated measure experiment (within-subject design)
Related Questions in SPREADSHEET
- Google Sheets script that automatically locks a sheet 24 hours after a cell is edited
- Excel Index+ match Returns duplicate value
- Add another criteria to a Google Sheet formula
- Assistance Required with PUT API Request to Update iSheet Column in HighQ
- How to sum monthly data in Excel into quarterly
- Sort Data in Google Sheets
- Spread single row into multiple in Google Sheets
- Return matching rows from Google Sheets matrix
- Convert 2D array indices to spreadsheet cell co-ordinates in JavaScript
- Looking for some ideas with how to reformat spreadsheet type data (excel, easymorph, etc..)
- Google sheets formula - how to change the value in one cell, depending on the values entered in a row range
- SumIf Importrange Function
- Using LEFT( ), RIGHT( ) and LEN( ) functions with custom formatted cells in excel
- Apps Script how to customize sheets
- Excel/Calc gives wrong comparison result (after sending file)
Related Questions in CAPSTONE
- Capstone cs_disasm disassembly only small portion of code
- Capstone Disassembler Java Bindings: "Invalid memory access"
- Capstone ethereum
- Does the Captone python module support an exe as input, or does the data need to be an isolated instruction binary?
- x86 assembly - how to identify register to register instructions
- SSE instruction addressing methods and operand types in virtual real mode / real mode / 16-bit protected mode
- I am having problem with sklearn.cluster and KMeans
- capstone disassembler python returns same instructions on every offset
- Converting date-time format for large dataset
- Foreign key constraint cannot add
- Edge Detection Limitations
- Grabbing data field by field and putting it into a Hashtable, trying to grab cols 3,4,5 and pair them with percentile via CSV file
- How to link against Capstone using CMake?
- capstone disassembler - disassembling single function without knowing length
- Capstone Disassemble from Binary File in Python
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Popular Tags
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)


One possible way would be importing the column as
STRINGand doing date parsing using the function:PARSE_DATETIME().%pwould handle string of "am, AM, pm, PM".