|
| 1 | +@file:ExcludeFromSources |
| 2 | + |
| 3 | +package org.jetbrains.kotlinx.dataframe.documentation |
| 4 | + |
| 5 | +import org.jetbrains.kotlinx.dataframe.DataFrame |
| 6 | +import org.jetbrains.kotlinx.dataframe.documentation.CommonReadDelimDocs.DataTitleArg |
| 7 | +import org.jetbrains.kotlinx.dataframe.documentation.CommonReadDelimDocs.FileTypeArg |
| 8 | +import org.jetbrains.kotlinx.dataframe.documentation.CommonReadDelimDocs.FileTypeTitleArg |
| 9 | +import org.jetbrains.kotlinx.dataframe.documentation.CommonReadDelimDocs.FunctionLinkArg |
| 10 | +import org.jetbrains.kotlinx.dataframe.documentation.CommonReadDelimDocs.OldFunctionLinkArg |
| 11 | +import org.jetbrains.kotlinx.dataframe.io.ColType |
| 12 | +import org.jetbrains.kotlinx.dataframe.io.DEFAULT_COL_TYPE |
| 13 | +import org.jetbrains.kotlinx.dataframe.io.DEFAULT_PARSER_OPTIONS |
| 14 | +import org.jetbrains.kotlinx.dataframe.io.ExperimentalCsv |
| 15 | +import java.io.File |
| 16 | +import java.io.InputStream |
| 17 | +import java.net.URL |
| 18 | +import java.util.Locale |
| 19 | + |
| 20 | +/** |
| 21 | + * ### Read $[FileTypeTitleArg] $[DataTitleArg] to [DataFrame] |
| 22 | + * |
| 23 | + * Reads any $[FileTypeArg] $[DataArg] to a [DataFrame][DataFrame]. |
| 24 | + * |
| 25 | + * Parameters you can use to customize the reading process include, for instance, \[delimiter\], |
| 26 | + * \[header\], \[colTypes\], \[readLines\], and \[parserOptions\]. |
| 27 | + * See the param list below for all settings. |
| 28 | + * |
| 29 | + * The integration is built upon {@include [DocumentationUrls.Deephaven]}. |
| 30 | + * |
| 31 | + * ##### Similar Functions |
| 32 | + * With the overloads of $[FunctionLinkArg]`()`, you can read any $[FileTypeArg] by [File][File], |
| 33 | + * [URL][URL], or [InputStream][InputStream]. |
| 34 | + * Reading by file path or URL can also be done by passing a [String]. |
| 35 | + * |
| 36 | + * For example, $[FunctionLinkArg]`("input.$[CommonReadDelimDocs.FileExtensionArg]")` or with some options: |
| 37 | + * |
| 38 | + * $[FunctionLinkArg]`(` |
| 39 | + * |
| 40 | + * {@include [Indent]}`file = `[File][File]`("input.$[CommonReadDelimDocs.FileExtensionArg]"),` |
| 41 | + * |
| 42 | + * {@include [Indent]}`parserOptions = `[DEFAULT_PARSER_OPTIONS][DEFAULT_PARSER_OPTIONS]`.copy(locale = `[Locale][Locale]`.`[US][Locale.US]`),` |
| 43 | + * |
| 44 | + * {@include [Indent]}`colTypes = `[mapOf][mapOf]`("a" `[to][to]` `[ColType][ColType]`.`[Int][ColType.Int]`, `[DEFAULT_COL_TYPE][DEFAULT_COL_TYPE]` `[to][to]` `[ColType][ColType]`.`[String][ColType.String]`),` |
| 45 | + * |
| 46 | + * {@include [Indent]}`readLines = 1000L,` |
| 47 | + * |
| 48 | + * `)` |
| 49 | + * |
| 50 | + * ZIP (.zip) or GZIP (.gz) files are supported by default. \[compression\] is automatically detected. |
| 51 | + * |
| 52 | + * You can also read "raw" $[FileTypeArg] data from a [String] like this: |
| 53 | + * |
| 54 | + * $[StrFunctionLinkArg]`("a,b,c", delimiter = ",")` |
| 55 | + * |
| 56 | + * _**NOTE EXPERIMENTAL**: This is a new set of functions, replacing the old $[OldFunctionLinkArg]`()` functions. |
| 57 | + * They'll hopefully be faster and better. Until they are proven to be so, |
| 58 | + * you'll need to [opt in][OptIn] to [ExperimentalCsv][ExperimentalCsv] to be able to use them._ |
| 59 | + * |
| 60 | + * @comment Some helper arguments for the function links |
| 61 | + * @set [FunctionLinkArg] \[DataFrame.${[FunctionNameArg]}\]\[${[FunctionNameArg]}\] |
| 62 | + * @set [StrFunctionLinkArg] \[DataFrame.${[FunctionNameArg]}Str\]\[${[FunctionNameArg]}Str\] |
| 63 | + * @set [OldFunctionLinkArg] \[DataFrame.${[OldFunctionNameArg]}\]\[org.jetbrains.kotlinx.dataframe.io.${[OldFunctionNameArg]}\] |
| 64 | + */ |
| 65 | +internal interface CommonReadDelimDocs { |
| 66 | + |
| 67 | + /** |
| 68 | + * @include [CommonReadDelimDocs] |
| 69 | + * @set [FileTypeTitleArg] CSV |
| 70 | + * @set [FileTypeArg] CSV |
| 71 | + * @set [FileExtensionArg] csv |
| 72 | + * @set [FunctionNameArg] readCsv |
| 73 | + * @set [OldFunctionNameArg] readCSV |
| 74 | + */ |
| 75 | + interface CsvDocs |
| 76 | + |
| 77 | + /** |
| 78 | + * @include [CommonReadDelimDocs] |
| 79 | + * @set [FileTypeTitleArg] TSV |
| 80 | + * @set [FileTypeArg] TSV |
| 81 | + * @set [FileExtensionArg] tsv |
| 82 | + * @set [FunctionNameArg] readTsv |
| 83 | + * @set [OldFunctionNameArg] readTSV |
| 84 | + */ |
| 85 | + interface TsvDocs |
| 86 | + |
| 87 | + /** |
| 88 | + * @include [CommonReadDelimDocs] |
| 89 | + * @set [FileTypeTitleArg] Delimiter-Separated Text |
| 90 | + * @set [FileTypeArg] delimiter-separated text |
| 91 | + * @set [FileExtensionArg] txt |
| 92 | + * @set [FunctionNameArg] readDelim |
| 93 | + * @set [OldFunctionNameArg] readDelim{@comment cannot differentiate between old and new} |
| 94 | + */ |
| 95 | + interface DelimDocs |
| 96 | + |
| 97 | + /** |
| 98 | + * @include [DelimParams.HEADER] |
| 99 | + * @include [DelimParams.COL_TYPES] |
| 100 | + * @include [DelimParams.SKIP_LINES] |
| 101 | + * @include [DelimParams.READ_LINES] |
| 102 | + * @include [DelimParams.PARSER_OPTIONS] |
| 103 | + * @include [DelimParams.IGNORE_EMPTY_LINES] |
| 104 | + * @include [DelimParams.ALLOW_MISSING_COLUMNS] |
| 105 | + * @include [DelimParams.IGNORE_EXCESS_COLUMNS] |
| 106 | + * @include [DelimParams.QUOTE] |
| 107 | + * @include [DelimParams.IGNORE_SURROUNDING_SPACES] |
| 108 | + * @include [DelimParams.TRIM_INSIDE_QUOTED] |
| 109 | + * @include [DelimParams.PARSE_PARALLEL] |
| 110 | + */ |
| 111 | + interface CommonReadParams |
| 112 | + |
| 113 | + // something like "File" or "File/URL" |
| 114 | + interface DataTitleArg |
| 115 | + |
| 116 | + // something like "file" or "file or url" |
| 117 | + interface DataArg |
| 118 | + |
| 119 | + // Like "CSV" or "TSV", capitalized |
| 120 | + interface FileTypeTitleArg |
| 121 | + |
| 122 | + // Like "CSV" or "TSV" |
| 123 | + interface FileTypeArg |
| 124 | + |
| 125 | + // like "csv" or "txt" |
| 126 | + interface FileExtensionArg |
| 127 | + |
| 128 | + // Function name, like "readCsv" |
| 129 | + interface FunctionNameArg |
| 130 | + |
| 131 | + // Old function name, like "readCSV" |
| 132 | + interface OldFunctionNameArg |
| 133 | + |
| 134 | + // A link to the main function, set by ReadDelim itself |
| 135 | + interface FunctionLinkArg |
| 136 | + |
| 137 | + // A link to the str function, set by ReadDelim itself |
| 138 | + interface StrFunctionLinkArg |
| 139 | + |
| 140 | + // A link to the old function, set by ReadDelim itself |
| 141 | + interface OldFunctionLinkArg |
| 142 | +} |
0 commit comments