Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "parse"

Index

Variables

Const dateKeyRegex

dateKeyRegex: RegExp = /^(\d{1,2})\/(\d{1,2})\/(\d{2})$/

The format of the date columns in the CSV files is "month/day/year", e.g. "1/2/20" for January 2, 2020. This is the regular expression for parsing them.

Functions

castCSVData

  • castCSVData(value: string, context: CastingContext): unknown
  • Casts the values read by the CSV reader to the correct types, and unifies column names used in different files.

    Parameters

    • value: string
    • context: CastingContext

    Returns unknown

dateKeyToDate

  • dateKeyToDate(dateKey: string): Date | undefined
  • Converts a string containing a date to a Date object, if it is in the right format, such as "1/2/20".

    Parameters

    • dateKey: string

      A string containing a date in the format "month/date/year", e.g. "1/2/20".

    Returns Date | undefined

dateToDateKey

  • dateToDateKey(date: Date): string
  • Converts the given Date object to a string in "month/day/year" format, e.g. "1/2/20".

    Parameters

    • date: Date

    Returns string

getDateKeys

  • getDateKeys(parsedCSV: ParsedCSV): string[]

getLocationInfoFromRow

getParserReadListener

  • getParserReadListener(parser: Parser, parsedCSV: ParsedCSV): () => void
  • Returns a function that the CSV parser can use to read each line of a CSV file and accumulate the read data in the given object.

    Parameters

    • parser: Parser
    • parsedCSV: ParsedCSV

      The ParsedCSV object that each read line is accumulated into.

    Returns () => void

      • (): void
      • Returns void

getProperColumnName

  • getProperColumnName(columnName: string): string
  • The CSV files containing the US county data have different column names than the files containing the global data. This method converts the US data column names to the ones we internally use (see columnTitles.

    Parameters

    • columnName: string

    Returns string

isDateKey

  • isDateKey(columnName: string): boolean
  • Returns true if the given column name is a date.

    Parameters

    • columnName: string

    Returns boolean

parseCSV

  • Parses the contents of a CSV file from the JHU CSSE time series data.

    Parameters

    • csv: string

    Returns Promise<ParsedCSV>

Object literals

Const columnTitles

columnTitles: object

The column names to use in parsed data objects.

county

county: string = "County"

population

population: string = "Population"

Const globalCSVColumnTitles

globalCSVColumnTitles: object

The column names in global data CSV files.

countryOrRegion

countryOrRegion: string = "Country/Region"

latitude

latitude: string = "Lat"

longitude

longitude: string = "Long"

provinceOrState

provinceOrState: string = "Province/State"

Const usCSVColumnTitles

usCSVColumnTitles: object

The column names in US data CSV files.

countryOrRegion

countryOrRegion: string = "Country_Region"

county

county: string = "Admin2"

longitude

longitude: string = "Long_"

provinceOrState

provinceOrState: string = "Province_State"

Generated using TypeDoc