Learn R Programming

readr (version 0.1.1)

count_fields: Count the number of fields in each line of a file.

Description

This is useful for diagnosing problems with functions that fail to parse correctly.

Usage

count_fields(file, tokenizer, skip = 0)

Arguments

file
Either a path to a file, a connection, or literal data (either a single string or a raw vector).

Files ending in .gz, .bz2, .xz, or .zip will be automatically uncompressed. Files starting with

tokenizer
A tokenizer that specifies how to break the file up into fields, e.g., tokenizer_csv, tokenizer_fwf
skip
Number of lines to skip before reading data.

Examples

Run this code
count_fields(system.file("extdata/mtcars.csv", package = "readr"),
 tokenizer_csv())

Run the code above in your browser using DataLab