td_to_csv() | Exporting data to CSV file | Teradata Package for R - td_to_csv() - Teradata Package for R

Teradata® Package for R User Guide

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Teradata Package for R
Release Number
17.20
Published
March 2024
ft:locale
en-US
ft:lastEdition
2024-04-09
dita:mapPath
efv1707506846369.ditamap
dita:ditavalPath
ayr1485454803741.ditaval
dita:id
nqx1518630623256
lifecycle
latest
Product Category
Teradata Vantage

The td_to_csv() function exports data from Teradata Vantage to CSV file with or without FastExport protocol.

Example Setup

  • Load the required tables into Vantage.
    > loadExampleData("time_series_example", "ocean_buoys_seq")
  • Create the "df_seq" object.
    # Create object(s) of class "tbl_teradata".
    > df_seq <- tbl(con, "ocean_buoys_seq")

Example 1: Export the data in a CSV file along with the errors and warnings, if any, while extracting the data

> val <- td_to_csv(df = df1,
                   csv.file.name = 'test.csv')

Example 2: Export the data without errors and warnings

> val <- td_to_csv(df = df1,
                   csv.file.name = 'test.csv',
                   catch.errors.warnings = FALSE)

Example 3: Export the data in a CSV file, with all.rows set to TRUE and catch errors and warnings, if any

> val <- td_to_csv(df = df1,
                   csv.file.name = 'test.csv',
                   all.rows = TRUE,
                   catch.errors.warnings = TRUE)

Example 4: Export the data in a CSV file using the specified field.quote.char and field.separator

> td_to_csv(df = df_seq,
            csv.file.name ="test.csv",
            field.separator=";",
            field.quote.char="'",
            catch.errors.warnings = FALSE)

Example 5: Export the data in a CSV file using FastExport

> td_to_csv(df = df_seq,
            csv.file.name ="test.csv",
            use.fastexport=TRUE,
            open.sessions = 4,
            catch.errors.warnings = FALSE)

Example 6: Export the data in a CSV file with specific number of rows

> td_to_csv(df = df_seq,
            csv.file.name ="test.csv",
            num.rows = 10500,
            catch.errors.warnings = FALSE)