summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2023-04-07 15:34:14 +0300
committerArnold D. Robbins <arnold@skeeve.com>2023-04-07 15:34:14 +0300
commitc71ae933f024fa4ff21a83038a6bebeb72efdc50 (patch)
treef8812fc6084d0dbf7e2e4e509bf5b87bb9d0e78b
parent2003b18129d4eb24011f9b39eb35c79598daf546 (diff)
downloadgawk-c71ae933f024fa4ff21a83038a6bebeb72efdc50.tar.gz
Add section in doc on generating CSV data.
-rw-r--r--awklib/eg/lib/tocsv.awk36
-rw-r--r--doc/ChangeLog4
-rw-r--r--doc/gawk.info1309
-rw-r--r--doc/gawk.texi87
-rw-r--r--doc/gawktexi.in87
5 files changed, 903 insertions, 620 deletions
diff --git a/awklib/eg/lib/tocsv.awk b/awklib/eg/lib/tocsv.awk
new file mode 100644
index 00000000..239822ad
--- /dev/null
+++ b/awklib/eg/lib/tocsv.awk
@@ -0,0 +1,36 @@
+# tocsv.awk --- convert data to CSV format
+#
+# Arnold Robbins, arnold@skeeve.com, Public Domain
+# April 2023
+
+function tocsv(fields, sep, i, j, nfields, result)
+{
+ if (length(fields) == 0)
+ return ""
+
+ if (sep == "")
+ sep = ","
+ delete nfields
+ for (i = 1; i in fields; i++) {
+ nfields[i] = fields[i]
+ if (nfields[i] ~ /["\n]/ || index(nfields[i], sep) != 0) {
+ gsub(/"/, "\"\"", nfields[i]) # double up quotes
+ nfields[i] = "\"" nfields[i] "\"" # wrap in quotes
+ }
+ }
+
+ result = nfields[1]
+ j = length(nfields)
+ for (i = 2; i <= j; i++)
+ result = result sep nfields[i]
+
+ return result
+}
+function tocsv_rec(sep, i, fields)
+{
+ delete feilds
+ for (i = 1; i <= NF; i++)
+ fields[i] = $i
+
+ return tocsv(fields, sep)
+}
diff --git a/doc/ChangeLog b/doc/ChangeLog
index 13e2f082..ac984601 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -1,3 +1,7 @@
+2023-04-07 Arnold D. Robbins <arnold@skeeve.com>
+
+ * gawktexi.in (To CSV Function): New section.
+
2023-04-06 Andrew J. Schorr <aschorr@telemetry-investments.com>
* gawktexi.in (Carriage-Return--Line-Feed Line Endings In CSV Files):
diff --git a/doc/gawk.info b/doc/gawk.info
index e3bcc9e7..721262a5 100644
--- a/doc/gawk.info
+++ b/doc/gawk.info
@@ -261,8 +261,8 @@ in (a) below. A copy of the license is included in the section entitled
Pipes.
* Close Return Value:: Using the return value from
‘close()’.
-* Nonfatal:: Enabling Nonfatal Output.
* Noflush:: Speeding Up Pipe Output.
+* Nonfatal:: Enabling Nonfatal Output.
* Output Summary:: Output summary.
* Output Exercises:: Exercises.
* Values:: Constants, Variables, and Regular
@@ -444,6 +444,8 @@ in (a) below. A copy of the license is included in the section entitled
shell.
* Isnumeric Function:: A function to test whether a value is
numeric.
+* To CSV Function:: A function to convert output to CSV
+ format.
* Data File Management:: Functions for managing command-line
data files.
* Filetrans Function:: A function for handling data file
@@ -16131,6 +16133,7 @@ programming use.
* Readfile Function:: A function to read an entire file at once.
* Shell Quoting:: A function to quote strings for the shell.
* Isnumeric Function:: A function to test whether a value is numeric.
+* To CSV Function:: A function to convert output to CSV format.

File: gawk.info, Node: Strtonum Function, Next: Assert Function, Up: General Functions
@@ -16718,7 +16721,7 @@ three-character string ‘"\"'\""’:
}

-File: gawk.info, Node: Isnumeric Function, Prev: Shell Quoting, Up: General Functions
+File: gawk.info, Node: Isnumeric Function, Next: To CSV Function, Prev: Shell Quoting, Up: General Functions
10.2.10 Checking Whether A Value Is Numeric
-------------------------------------------
@@ -16755,6 +16758,69 @@ yield the original string. On the other hand, it uses the ‘typeof()’
function (*note Type Functions::), which is specific to ‘gawk’.

+File: gawk.info, Node: To CSV Function, Prev: Isnumeric Function, Up: General Functions
+
+10.2.11 Producing CSV Data
+--------------------------
+
+‘gawk’’s ‘--csv’ option causes ‘gawk’ to process CSV data (*note Comma
+Separated Fields::).
+
+ But what if you have regular data that you want to output in CSV
+format? This minor node provides functions for doing that.
+
+ The first function, ‘tocsv()’, takes an array of data fields as
+input. The array should be indexed starting from one. The optional
+second parameter is the separator to use. If none is supplied, the
+default is a comma.
+
+ The function takes care to quote fields that contain double quotes,
+newlines, or the separator character. It then builds up the final CSV
+record and returns it.
+
+ # tocsv.awk --- convert data to CSV format
+
+ function tocsv(fields, sep, i, j, nfields, result)
+ {
+ if (length(fields) == 0)
+ return ""
+
+ if (sep == "")
+ sep = ","
+ delete nfields
+ for (i = 1; i in fields; i++) {
+ nfields[i] = fields[i]
+ if (nfields[i] ~ /["\n]/ || index(nfields[i], sep) != 0) {
+ gsub(/"/, "\"\"", nfields[i]) # double up quotes
+ nfields[i] = "\"" nfields[i] "\"" # wrap in quotes
+ }
+ }
+
+ result = nfields[1]
+ j = length(nfields)
+ for (i = 2; i <= j; i++)
+ result = result sep nfields[i]
+
+ return result
+ }
+
+ The next function, ‘tocsv_rec()’ is a wrapper around ‘tocsv()’. Its
+intended use is for when you want to convert the current input record to
+CSV format. The function itself simply copies the fields into an array
+to pass to ‘tocsv()’ which does the work. It accepts an optional
+separator character as its first parameter, which it simply passes on to
+‘tocsv()’.
+
+ function tocsv_rec(sep, i, fields)
+ {
+ delete feilds
+ for (i = 1; i <= NF; i++)
+ fields[i] = $i
+
+ return tocsv(fields, sep)
+ }
+
+
File: gawk.info, Node: Data File Management, Next: Getopt Function, Prev: General Functions, Up: Library Functions
10.3 Data file Management
@@ -36788,6 +36854,8 @@ Index
(line 23)
* Comma separated values (CSV) data, parsing with FPAT library: More CSV.
(line 52)
+* comma separated values (CSV) data, generating CSV data: To CSV Function.
+ (line 6)
* command completion, in debugger: Readline Support. (line 6)
* command line, formats: Running gawk. (line 12)
* command line, option -f: Long. (line 12)
@@ -36912,6 +36980,8 @@ Index
(line 23)
* CSV (comma separated values) data, parsing with CSVMODE library: More CSV.
(line 52)
+* CSV (comma separated values) data, generating CSV data: To CSV Function.
+ (line 6)
* CSVMODE library for gawk: More CSV. (line 52)
* ctime() user-defined function: Function Example. (line 74)
* Curreli, Marco: Contributors. (line 147)
@@ -39339,6 +39409,8 @@ Index
* timestamps, converting dates to: Time Functions. (line 77)
* timestamps, formatted: Getlocaltime Function.
(line 6)
+* tocsv() user-defined function: To CSV Function. (line 21)
+* tocsv_rec() user-defined function: To CSV Function. (line 54)
* tolower: String Functions. (line 548)
* toupper: String Functions. (line 554)
* tr utility: Translate Program. (line 6)
@@ -39575,622 +39647,623 @@ Index

Tag Table:
Node: Top1229
-Node: Foreword346808
-Node: Foreword451408
-Node: Preface52957
-Ref: Preface-Footnote-155949
-Ref: Preface-Footnote-256058
-Ref: Preface-Footnote-356292
-Node: History56438
-Node: Names59056
-Ref: Names-Footnote-160219
-Node: This Manual60382
-Ref: This Manual-Footnote-167332
-Node: Conventions67444
-Node: Manual History69922
-Ref: Manual History-Footnote-172959
-Ref: Manual History-Footnote-273006
-Node: How To Contribute73084
-Node: Acknowledgments74034
-Node: Getting Started79032
-Node: Running gawk81559
-Node: One-shot82777
-Node: Read Terminal84080
-Node: Long86140
-Node: Executable Scripts87721
-Ref: Executable Scripts-Footnote-190496
-Node: Comments90603
-Node: Quoting93141
-Node: DOS Quoting98790
-Node: Sample Data Files100876
-Node: Very Simple103513
-Node: Two Rules109792
-Node: More Complex111746
-Node: Statements/Lines114186
-Ref: Statements/Lines-Footnote-1119066
-Node: Other Features119355
-Node: When120323
-Ref: When-Footnote-1122129
-Node: Intro Summary122194
-Node: Invoking Gawk123150
-Node: Command Line124720
-Node: Options125571
-Ref: Options-Footnote-1144948
-Ref: Options-Footnote-2145183
-Node: Other Arguments145208
-Node: Naming Standard Input149385
-Node: Environment Variables150655
-Node: AWKPATH Variable151229
-Ref: AWKPATH Variable-Footnote-1154819
-Ref: AWKPATH Variable-Footnote-2154853
-Node: AWKLIBPATH Variable155246
-Ref: AWKLIBPATH Variable-Footnote-1157021
-Node: Other Environment Variables157418
-Node: Exit Status161914
-Node: Include Files162629
-Node: Loading Shared Libraries166689
-Node: Obsolete168181
-Node: Undocumented168817
-Node: Invoking Summary169116
-Node: Regexp172143
-Node: Regexp Usage173637
-Node: Escape Sequences175738
-Node: Regexp Operators183074
-Node: Regexp Operator Details183567
-Ref: Regexp Operator Details-Footnote-1191433
-Node: Interval Expressions191592
-Ref: Interval Expressions-Footnote-1193861
-Node: Bracket Expressions193961
-Ref: table-char-classes196521
-Node: Leftmost Longest200043
-Node: Computed Regexps201403
-Node: GNU Regexp Operators204926
-Node: Case-sensitivity208949
-Ref: Case-sensitivity-Footnote-1211906
-Ref: Case-sensitivity-Footnote-2212151
-Node: Regexp Summary212267
-Node: Reading Files213791
-Node: Records216108
-Node: awk split records217383
-Node: gawk split records222273
-Ref: gawk split records-Footnote-1227567
-Node: Fields227604
-Node: Nonconstant Fields230491
-Ref: Nonconstant Fields-Footnote-1232802
-Node: Changing Fields233018
-Node: Field Separators239326
-Node: Default Field Splitting242199
-Node: Regexp Field Splitting243342
-Node: Single Character Fields247171
-Node: Comma Separated Fields248260
-Ref: table-csv-examples249679
-Node: Command Line Field Separator251689
-Node: Full Line Fields255075
-Ref: Full Line Fields-Footnote-1256655
-Ref: Full Line Fields-Footnote-2256701
-Node: Field Splitting Summary256809
-Node: Constant Size259243
-Node: Fixed width data259987
-Node: Skipping intervening263506
-Node: Allowing trailing data264308
-Node: Fields with fixed data265373
-Node: Splitting By Content266999
-Ref: Splitting By Content-Footnote-1271268
-Node: More CSV271431
-Node: FS versus FPAT273084
-Node: Testing field creation274293
-Node: Multiple Line276071
-Node: Getline282553
-Node: Plain Getline285139
-Node: Getline/Variable287789
-Node: Getline/File288986
-Node: Getline/Variable/File290434
-Ref: Getline/Variable/File-Footnote-1292079
-Node: Getline/Pipe292175
-Node: Getline/Variable/Pipe294988
-Node: Getline/Coprocess296171
-Node: Getline/Variable/Coprocess297494
-Node: Getline Notes298260
-Node: Getline Summary301221
-Ref: table-getline-variants301665
-Node: Read Timeout302570
-Ref: Read Timeout-Footnote-1306534
-Node: Retrying Input306592
-Node: Command-line directories307859
-Node: Input Summary308797
-Node: Input Exercises312177
-Node: Printing312617
-Node: Print314560
-Node: Print Examples316066
-Node: Output Separators318919
-Node: OFMT321030
-Node: Printf322453
-Node: Basic Printf323258
-Node: Control Letters324894
-Node: Format Modifiers330363
-Node: Printf Examples336649
-Node: Redirection339194
-Node: Special FD346268
-Ref: Special FD-Footnote-1349558
-Node: Special Files349644
-Node: Other Inherited Files350273
-Node: Special Network351338
-Node: Special Caveats352226
-Node: Close Files And Pipes353209
-Ref: Close Files And Pipes-Footnote-1359345
-Node: Close Return Value359501
-Ref: table-close-pipe-return-values360776
-Ref: Close Return Value-Footnote-1361610
-Node: Noflush361766
-Node: Nonfatal363278
-Node: Output Summary365695
-Node: Output Exercises366981
-Node: Expressions367672
-Node: Values368874
-Node: Constants369552
-Node: Scalar Constants370249
-Ref: Scalar Constants-Footnote-1372827
-Ref: Scalar Constants-Footnote-2373077
-Node: Nondecimal-numbers373157
-Node: Regexp Constants376278
-Node: Using Constant Regexps376824
-Node: Standard Regexp Constants377470
-Node: Strong Regexp Constants380770
-Node: Variables384621
-Node: Using Variables385286
-Node: Assignment Options387266
-Node: Conversion389828
-Node: Strings And Numbers390360
-Ref: Strings And Numbers-Footnote-1393579
-Node: Locale influences conversions393688
-Ref: table-locale-affects396538
-Node: All Operators397181
-Node: Arithmetic Ops397822
-Node: Concatenation400652
-Ref: Concatenation-Footnote-1403602
-Node: Assignment Ops403725
-Ref: table-assign-ops408864
-Node: Increment Ops410246
-Node: Truth Values and Conditions413845
-Node: Truth Values414971
-Node: Typing and Comparison416062
-Node: Variable Typing416898
-Ref: Variable Typing-Footnote-1423560
-Ref: Variable Typing-Footnote-2423640
-Node: Comparison Operators423723
-Ref: table-relational-ops424150
-Node: POSIX String Comparison427836
-Ref: POSIX String Comparison-Footnote-1429595
-Ref: POSIX String Comparison-Footnote-2429738
-Node: Boolean Ops429822
-Ref: Boolean Ops-Footnote-1434515
-Node: Conditional Exp434611
-Node: Function Calls436397
-Node: Precedence440347
-Node: Locales444224
-Node: Expressions Summary445906
-Node: Patterns and Actions448569
-Node: Pattern Overview449711
-Node: Regexp Patterns451437
-Node: Expression Patterns451983
-Node: Ranges455892
-Node: BEGIN/END459070
-Node: Using BEGIN/END459883
-Ref: Using BEGIN/END-Footnote-1462793
-Node: I/O And BEGIN/END462903
-Node: BEGINFILE/ENDFILE465384
-Node: Empty468825
-Node: Using Shell Variables469142
-Node: Action Overview471480
-Node: Statements473915
-Node: If Statement475813
-Node: While Statement477382
-Node: Do Statement479470
-Node: For Statement480656
-Node: Switch Statement484013
-Node: Break Statement486564
-Node: Continue Statement488756
-Node: Next Statement490688
-Node: Nextfile Statement493185
-Node: Exit Statement496046
-Node: Built-in Variables498579
-Node: User-modified499758
-Node: Auto-set507969
-Ref: Auto-set-Footnote-1526068
-Ref: Auto-set-Footnote-2526286
-Node: ARGC and ARGV526342
-Node: Pattern Action Summary530781
-Node: Arrays533397
-Node: Array Basics534774
-Node: Array Intro535624
-Ref: figure-array-elements537640
-Ref: Array Intro-Footnote-1540509
-Node: Reference to Elements540641
-Node: Assigning Elements543163
-Node: Array Example543658
-Node: Scanning an Array545627
-Node: Controlling Scanning548724
-Ref: Controlling Scanning-Footnote-1555370
-Node: Numeric Array Subscripts555694
-Node: Uninitialized Subscripts557968
-Node: Delete559647
-Ref: Delete-Footnote-1562461
-Node: Multidimensional562518
-Node: Multiscanning565723
-Node: Arrays of Arrays567395
-Node: Arrays Summary572295
-Node: Functions574484
-Node: Built-in575544
-Node: Calling Built-in576733
-Node: Boolean Functions578780
-Node: Numeric Functions579350
-Ref: Numeric Functions-Footnote-1583543
-Ref: Numeric Functions-Footnote-2584227
-Ref: Numeric Functions-Footnote-3584279
-Node: String Functions584555
-Ref: String Functions-Footnote-1610786
-Ref: String Functions-Footnote-2610920
-Ref: String Functions-Footnote-3611180
-Node: Gory Details611267
-Ref: table-sub-escapes613174
-Ref: table-sub-proposed614820
-Ref: table-posix-sub616330
-Ref: table-gensub-escapes618018
-Ref: Gory Details-Footnote-1618952
-Node: I/O Functions619106
-Ref: table-system-return-values625793
-Ref: I/O Functions-Footnote-1627964
-Ref: I/O Functions-Footnote-2628112
-Node: Time Functions628232
-Ref: Time Functions-Footnote-1639388
-Ref: Time Functions-Footnote-2639464
-Ref: Time Functions-Footnote-3639626
-Ref: Time Functions-Footnote-4639737
-Ref: Time Functions-Footnote-5639855
-Ref: Time Functions-Footnote-6640090
-Node: Bitwise Functions640372
-Ref: table-bitwise-ops640974
-Ref: Bitwise Functions-Footnote-1647228
-Ref: Bitwise Functions-Footnote-2647407
-Node: Type Functions647604
-Node: I18N Functions651197
-Node: User-defined652940
-Node: Definition Syntax653760
-Ref: Definition Syntax-Footnote-1659588
-Node: Function Example659665
-Ref: Function Example-Footnote-1662644
-Node: Function Calling662666
-Node: Calling A Function663260
-Node: Variable Scope664230
-Node: Pass By Value/Reference667284
-Node: Function Caveats670016
-Ref: Function Caveats-Footnote-1672111
-Node: Return Statement672235
-Node: Dynamic Typing675290
-Node: Indirect Calls677682
-Node: Functions Summary688841
-Node: Library Functions691618
-Ref: Library Functions-Footnote-1695166
-Ref: Library Functions-Footnote-2695309
-Node: Library Names695484
-Ref: Library Names-Footnote-1699278
-Ref: Library Names-Footnote-2699505
-Node: General Functions699601
-Node: Strtonum Function700795
-Node: Assert Function703877
-Node: Round Function707329
-Node: Cliff Random Function708907
-Node: Ordinal Functions709940
-Ref: Ordinal Functions-Footnote-1713049
-Ref: Ordinal Functions-Footnote-2713301
-Node: Join Function713515
-Ref: Join Function-Footnote-1715318
-Node: Getlocaltime Function715522
-Node: Readfile Function719296
-Node: Shell Quoting721325
-Node: Isnumeric Function722781
-Node: Data File Management724193
-Node: Filetrans Function724825
-Node: Rewind Function729119
-Node: File Checking731098
-Ref: File Checking-Footnote-1732470
-Node: Empty Files732677
-Node: Ignoring Assigns734744
-Node: Getopt Function736318
-Ref: Getopt Function-Footnote-1752152
-Node: Passwd Functions752364
-Ref: Passwd Functions-Footnote-1761546
-Node: Group Functions761634
-Ref: Group Functions-Footnote-1769772
-Node: Walking Arrays769985
-Node: Library Functions Summary773033
-Node: Library Exercises774457
-Node: Sample Programs774944
-Node: Running Examples775726
-Node: Clones776478
-Node: Cut Program777750
-Node: Egrep Program788191
-Node: Id Program797508
-Node: Split Program807622
-Ref: Split Program-Footnote-1817857
-Node: Tee Program818044
-Node: Uniq Program820953
-Node: Wc Program828818
-Node: Bytes vs. Characters829213
-Node: Using extensions830815
-Node: wc program831595
-Node: Miscellaneous Programs836601
-Node: Dupword Program837830
-Node: Alarm Program839893
-Node: Translate Program844806
-Ref: Translate Program-Footnote-1849547
-Node: Labels Program849825
-Ref: Labels Program-Footnote-1853266
-Node: Word Sorting853358
-Node: History Sorting857552
-Node: Extract Program859827
-Node: Simple Sed868096
-Node: Igawk Program871312
-Ref: Igawk Program-Footnote-1886559
-Ref: Igawk Program-Footnote-2886765
-Ref: Igawk Program-Footnote-3886895
-Node: Anagram Program887022
-Node: Signature Program890118
-Node: Programs Summary891370
-Node: Programs Exercises892628
-Ref: Programs Exercises-Footnote-1896944
-Node: Advanced Features897030
-Node: Nondecimal Data899524
-Node: Boolean Typed Values901154
-Node: Array Sorting903129
-Node: Controlling Array Traversal903858
-Ref: Controlling Array Traversal-Footnote-1912365
-Node: Array Sorting Functions912487
-Ref: Array Sorting Functions-Footnote-1918606
-Node: Two-way I/O918814
-Ref: Two-way I/O-Footnote-1926809
-Ref: Two-way I/O-Footnote-2927000
-Node: TCP/IP Networking927082
-Node: Profiling930262
-Node: Persistent Memory939972
-Ref: Persistent Memory-Footnote-1948930
-Node: Extension Philosophy949061
-Node: Advanced Features Summary950596
-Node: Internationalization952866
-Node: I18N and L10N954572
-Node: Explaining gettext955267
-Ref: Explaining gettext-Footnote-1961420
-Ref: Explaining gettext-Footnote-2961615
-Node: Programmer i18n961780
-Ref: Programmer i18n-Footnote-1966893
-Node: Translator i18n966942
-Node: String Extraction967778
-Ref: String Extraction-Footnote-1968956
-Node: Printf Ordering969054
-Ref: Printf Ordering-Footnote-1971916
-Node: I18N Portability971984
-Ref: I18N Portability-Footnote-1974558
-Node: I18N Example974629
-Ref: I18N Example-Footnote-1978029
-Ref: I18N Example-Footnote-2978105
-Node: Gawk I18N978222
-Node: I18N Summary978878
-Node: Debugger980279
-Node: Debugging981303
-Node: Debugging Concepts981752
-Node: Debugging Terms983578
-Node: Awk Debugging986191
-Ref: Awk Debugging-Footnote-1987168
-Node: Sample Debugging Session987308
-Node: Debugger Invocation987860
-Node: Finding The Bug989489
-Node: List of Debugger Commands996175
-Node: Breakpoint Control997552
-Node: Debugger Execution Control1001384
-Node: Viewing And Changing Data1004864
-Node: Execution Stack1008602
-Node: Debugger Info1010283
-Node: Miscellaneous Debugger Commands1014582
-Node: Readline Support1019835
-Node: Limitations1020781
-Node: Debugging Summary1023425
-Node: Namespaces1024728
-Node: Global Namespace1025855
-Node: Qualified Names1027300
-Node: Default Namespace1028335
-Node: Changing The Namespace1029110
-Node: Naming Rules1030804
-Node: Internal Name Management1032719
-Node: Namespace Example1033789
-Node: Namespace And Features1036372
-Node: Namespace Summary1037829
-Node: Arbitrary Precision Arithmetic1039342
-Node: Computer Arithmetic1040861
-Ref: table-numeric-ranges1044678
-Ref: table-floating-point-ranges1045176
-Ref: Computer Arithmetic-Footnote-11045835
-Node: Math Definitions1045894
-Ref: table-ieee-formats1048939
-Node: MPFR features1049513
-Node: MPFR On Parole1049966
-Ref: MPFR On Parole-Footnote-11050810
-Node: MPFR Intro1050969
-Node: FP Math Caution1052659
-Ref: FP Math Caution-Footnote-11053733
-Node: Inexactness of computations1054110
-Node: Inexact representation1055141
-Node: Comparing FP Values1056524
-Node: Errors accumulate1057782
-Node: Strange values1059249
-Ref: Strange values-Footnote-11061915
-Node: Getting Accuracy1062020
-Node: Try To Round1064757
-Node: Setting precision1065664
-Ref: table-predefined-precision-strings1066369
-Node: Setting the rounding mode1068254
-Ref: table-gawk-rounding-modes1068636
-Ref: Setting the rounding mode-Footnote-11072694
-Node: Arbitrary Precision Integers1072877
-Ref: Arbitrary Precision Integers-Footnote-11076089
-Node: Checking for MPFR1076245
-Node: POSIX Floating Point Problems1077735
-Ref: POSIX Floating Point Problems-Footnote-11082599
-Node: Floating point summary1082637
-Node: Dynamic Extensions1084901
-Node: Extension Intro1086500
-Node: Plugin License1087808
-Node: Extension Mechanism Outline1088621
-Ref: figure-load-extension1089072
-Ref: figure-register-new-function1090657
-Ref: figure-call-new-function1091767
-Node: Extension API Description1093891
-Node: Extension API Functions Introduction1095620
-Ref: table-api-std-headers1097518
-Node: General Data Types1101982
-Ref: General Data Types-Footnote-11111150
-Node: Memory Allocation Functions1111465
-Ref: Memory Allocation Functions-Footnote-11116190
-Node: Constructor Functions1116289
-Node: API Ownership of MPFR and GMP Values1120194
-Node: Registration Functions1121755
-Node: Extension Functions1122459
-Node: Exit Callback Functions1128035
-Node: Extension Version String1129354
-Node: Input Parsers1130049
-Node: Output Wrappers1144693
-Node: Two-way processors1149541
-Node: Printing Messages1151902
-Ref: Printing Messages-Footnote-11153116
-Node: Updating ERRNO1153271
-Node: Requesting Values1154070
-Ref: table-value-types-returned1154823
-Node: Accessing Parameters1155932
-Node: Symbol Table Access1157216
-Node: Symbol table by name1157732
-Ref: Symbol table by name-Footnote-11160943
-Node: Symbol table by cookie1161075
-Ref: Symbol table by cookie-Footnote-11165356
-Node: Cached values1165420
-Ref: Cached values-Footnote-11169064
-Node: Array Manipulation1169221
-Ref: Array Manipulation-Footnote-11170324
-Node: Array Data Types1170361
-Ref: Array Data Types-Footnote-11173183
-Node: Array Functions1173283
-Node: Flattening Arrays1178312
-Node: Creating Arrays1185364
-Node: Redirection API1190214
-Node: Extension API Variables1193235
-Node: Extension Versioning1193960
-Ref: gawk-api-version1194397
-Node: Extension GMP/MPFR Versioning1196185
-Node: Extension API Informational Variables1197891
-Node: Extension API Boilerplate1199052
-Node: Changes from API V11203188
-Node: Finding Extensions1204822
-Node: Extension Example1205397
-Node: Internal File Description1206221
-Node: Internal File Ops1210545
-Ref: Internal File Ops-Footnote-11222103
-Node: Using Internal File Ops1222251
-Ref: Using Internal File Ops-Footnote-11224682
-Node: Extension Samples1224960
-Node: Extension Sample File Functions1226529
-Node: Extension Sample Fnmatch1234667
-Node: Extension Sample Fork1236262
-Node: Extension Sample Inplace1237538
-Node: Extension Sample Ord1241210
-Node: Extension Sample Readdir1242086
-Ref: table-readdir-file-types1242983
-Node: Extension Sample Revout1244121
-Node: Extension Sample Rev2way1244718
-Node: Extension Sample Read write array1245470
-Node: Extension Sample Readfile1248744
-Node: Extension Sample Time1249875
-Node: Extension Sample API Tests1252165
-Node: gawkextlib1252673
-Node: Extension summary1255709
-Node: Extension Exercises1259567
-Node: Language History1260845
-Node: V7/SVR3.11262559
-Node: SVR41264909
-Node: POSIX1266441
-Node: BTL1267866
-Node: POSIX/GNU1268635
-Node: Feature History1275166
-Node: Common Extensions1294733
-Node: Ranges and Locales1296210
-Ref: Ranges and Locales-Footnote-11301011
-Ref: Ranges and Locales-Footnote-21301038
-Ref: Ranges and Locales-Footnote-31301277
-Node: Contributors1301500
-Node: History summary1307705
-Node: Installation1309151
-Node: Gawk Distribution1310115
-Node: Getting1310607
-Node: Extracting1311606
-Node: Distribution contents1313318
-Node: Unix Installation1321398
-Node: Quick Installation1322220
-Node: Compiling with MPFR1324766
-Node: Shell Startup Files1325472
-Node: Additional Configuration Options1326629
-Node: Configuration Philosophy1329016
-Node: Compiling from Git1331518
-Node: Building the Documentation1332077
-Node: Non-Unix Installation1333489
-Node: PC Installation1333965
-Node: PC Binary Installation1334838
-Node: PC Compiling1335743
-Node: PC Using1336921
-Node: Cygwin1340649
-Node: MSYS1341905
-Node: OpenVMS Installation1342537
-Node: OpenVMS Compilation1343218
-Ref: OpenVMS Compilation-Footnote-11344701
-Node: OpenVMS Dynamic Extensions1344763
-Node: OpenVMS Installation Details1346399
-Node: OpenVMS Running1348834
-Node: OpenVMS GNV1352971
-Node: Bugs1353726
-Node: Bug definition1354650
-Node: Bug address1358301
-Node: Usenet1361892
-Node: Performance bugs1363123
-Node: Asking for help1366141
-Node: Maintainers1368132
-Node: Other Versions1369159
-Node: Installation summary1378091
-Node: Notes1379475
-Node: Compatibility Mode1380285
-Node: Additions1381107
-Node: Accessing The Source1382052
-Node: Adding Code1383587
-Node: New Ports1390723
-Node: Derived Files1395233
-Ref: Derived Files-Footnote-11401080
-Ref: Derived Files-Footnote-21401115
-Ref: Derived Files-Footnote-31401732
-Node: Future Extensions1401846
-Node: Implementation Limitations1402518
-Node: Extension Design1403760
-Node: Old Extension Problems1404924
-Ref: Old Extension Problems-Footnote-11406500
-Node: Extension New Mechanism Goals1406561
-Ref: Extension New Mechanism Goals-Footnote-11410057
-Node: Extension Other Design Decisions1410258
-Node: Extension Future Growth1412457
-Node: Notes summary1413081
-Node: Basic Concepts1414294
-Node: Basic High Level1414979
-Ref: figure-general-flow1415261
-Ref: figure-process-flow1415968
-Ref: Basic High Level-Footnote-11419369
-Node: Basic Data Typing1419558
-Node: Glossary1422976
-Node: Copying1456098
-Node: GNU Free Documentation License1493859
-Node: Index1519182
+Node: Foreword346932
+Node: Foreword451532
+Node: Preface53081
+Ref: Preface-Footnote-156073
+Ref: Preface-Footnote-256182
+Ref: Preface-Footnote-356416
+Node: History56562
+Node: Names59180
+Ref: Names-Footnote-160343
+Node: This Manual60506
+Ref: This Manual-Footnote-167456
+Node: Conventions67568
+Node: Manual History70046
+Ref: Manual History-Footnote-173083
+Ref: Manual History-Footnote-273130
+Node: How To Contribute73208
+Node: Acknowledgments74158
+Node: Getting Started79156
+Node: Running gawk81683
+Node: One-shot82901
+Node: Read Terminal84204
+Node: Long86264
+Node: Executable Scripts87845
+Ref: Executable Scripts-Footnote-190620
+Node: Comments90727
+Node: Quoting93265
+Node: DOS Quoting98914
+Node: Sample Data Files101000
+Node: Very Simple103637
+Node: Two Rules109916
+Node: More Complex111870
+Node: Statements/Lines114310
+Ref: Statements/Lines-Footnote-1119190
+Node: Other Features119479
+Node: When120447
+Ref: When-Footnote-1122253
+Node: Intro Summary122318
+Node: Invoking Gawk123274
+Node: Command Line124844
+Node: Options125695
+Ref: Options-Footnote-1145072
+Ref: Options-Footnote-2145307
+Node: Other Arguments145332
+Node: Naming Standard Input149509
+Node: Environment Variables150779
+Node: AWKPATH Variable151353
+Ref: AWKPATH Variable-Footnote-1154943
+Ref: AWKPATH Variable-Footnote-2154977
+Node: AWKLIBPATH Variable155370
+Ref: AWKLIBPATH Variable-Footnote-1157145
+Node: Other Environment Variables157542
+Node: Exit Status162038
+Node: Include Files162753
+Node: Loading Shared Libraries166813
+Node: Obsolete168305
+Node: Undocumented168941
+Node: Invoking Summary169240
+Node: Regexp172267
+Node: Regexp Usage173761
+Node: Escape Sequences175862
+Node: Regexp Operators183198
+Node: Regexp Operator Details183691
+Ref: Regexp Operator Details-Footnote-1191557
+Node: Interval Expressions191716
+Ref: Interval Expressions-Footnote-1193985
+Node: Bracket Expressions194085
+Ref: table-char-classes196645
+Node: Leftmost Longest200167
+Node: Computed Regexps201527
+Node: GNU Regexp Operators205050
+Node: Case-sensitivity209073
+Ref: Case-sensitivity-Footnote-1212030
+Ref: Case-sensitivity-Footnote-2212275
+Node: Regexp Summary212391
+Node: Reading Files213915
+Node: Records216232
+Node: awk split records217507
+Node: gawk split records222397
+Ref: gawk split records-Footnote-1227691
+Node: Fields227728
+Node: Nonconstant Fields230615
+Ref: Nonconstant Fields-Footnote-1232926
+Node: Changing Fields233142
+Node: Field Separators239450
+Node: Default Field Splitting242323
+Node: Regexp Field Splitting243466
+Node: Single Character Fields247295
+Node: Comma Separated Fields248384
+Ref: table-csv-examples249803
+Node: Command Line Field Separator251813
+Node: Full Line Fields255199
+Ref: Full Line Fields-Footnote-1256779
+Ref: Full Line Fields-Footnote-2256825
+Node: Field Splitting Summary256933
+Node: Constant Size259367
+Node: Fixed width data260111
+Node: Skipping intervening263630
+Node: Allowing trailing data264432
+Node: Fields with fixed data265497
+Node: Splitting By Content267123
+Ref: Splitting By Content-Footnote-1271392
+Node: More CSV271555
+Node: FS versus FPAT273208
+Node: Testing field creation274417
+Node: Multiple Line276195
+Node: Getline282677
+Node: Plain Getline285263
+Node: Getline/Variable287913
+Node: Getline/File289110
+Node: Getline/Variable/File290558
+Ref: Getline/Variable/File-Footnote-1292203
+Node: Getline/Pipe292299
+Node: Getline/Variable/Pipe295112
+Node: Getline/Coprocess296295
+Node: Getline/Variable/Coprocess297618
+Node: Getline Notes298384
+Node: Getline Summary301345
+Ref: table-getline-variants301789
+Node: Read Timeout302694
+Ref: Read Timeout-Footnote-1306658
+Node: Retrying Input306716
+Node: Command-line directories307983
+Node: Input Summary308921
+Node: Input Exercises312301
+Node: Printing312741
+Node: Print314684
+Node: Print Examples316190
+Node: Output Separators319043
+Node: OFMT321154
+Node: Printf322577
+Node: Basic Printf323382
+Node: Control Letters325018
+Node: Format Modifiers330487
+Node: Printf Examples336773
+Node: Redirection339318
+Node: Special FD346392
+Ref: Special FD-Footnote-1349682
+Node: Special Files349768
+Node: Other Inherited Files350397
+Node: Special Network351462
+Node: Special Caveats352350
+Node: Close Files And Pipes353333
+Ref: Close Files And Pipes-Footnote-1359469
+Node: Close Return Value359625
+Ref: table-close-pipe-return-values360900
+Ref: Close Return Value-Footnote-1361734
+Node: Noflush361890
+Node: Nonfatal363402
+Node: Output Summary365819
+Node: Output Exercises367105
+Node: Expressions367796
+Node: Values368998
+Node: Constants369676
+Node: Scalar Constants370373
+Ref: Scalar Constants-Footnote-1372951
+Ref: Scalar Constants-Footnote-2373201
+Node: Nondecimal-numbers373281
+Node: Regexp Constants376402
+Node: Using Constant Regexps376948
+Node: Standard Regexp Constants377594
+Node: Strong Regexp Constants380894
+Node: Variables384745
+Node: Using Variables385410
+Node: Assignment Options387390
+Node: Conversion389952
+Node: Strings And Numbers390484
+Ref: Strings And Numbers-Footnote-1393703
+Node: Locale influences conversions393812
+Ref: table-locale-affects396662
+Node: All Operators397305
+Node: Arithmetic Ops397946
+Node: Concatenation400776
+Ref: Concatenation-Footnote-1403726
+Node: Assignment Ops403849
+Ref: table-assign-ops408988
+Node: Increment Ops410370
+Node: Truth Values and Conditions413969
+Node: Truth Values415095
+Node: Typing and Comparison416186
+Node: Variable Typing417022
+Ref: Variable Typing-Footnote-1423684
+Ref: Variable Typing-Footnote-2423764
+Node: Comparison Operators423847
+Ref: table-relational-ops424274
+Node: POSIX String Comparison427960
+Ref: POSIX String Comparison-Footnote-1429719
+Ref: POSIX String Comparison-Footnote-2429862
+Node: Boolean Ops429946
+Ref: Boolean Ops-Footnote-1434639
+Node: Conditional Exp434735
+Node: Function Calls436521
+Node: Precedence440471
+Node: Locales444348
+Node: Expressions Summary446030
+Node: Patterns and Actions448693
+Node: Pattern Overview449835
+Node: Regexp Patterns451561
+Node: Expression Patterns452107
+Node: Ranges456016
+Node: BEGIN/END459194
+Node: Using BEGIN/END460007
+Ref: Using BEGIN/END-Footnote-1462917
+Node: I/O And BEGIN/END463027
+Node: BEGINFILE/ENDFILE465508
+Node: Empty468949
+Node: Using Shell Variables469266
+Node: Action Overview471604
+Node: Statements474039
+Node: If Statement475937
+Node: While Statement477506
+Node: Do Statement479594
+Node: For Statement480780
+Node: Switch Statement484137
+Node: Break Statement486688
+Node: Continue Statement488880
+Node: Next Statement490812
+Node: Nextfile Statement493309
+Node: Exit Statement496170
+Node: Built-in Variables498703
+Node: User-modified499882
+Node: Auto-set508093
+Ref: Auto-set-Footnote-1526192
+Ref: Auto-set-Footnote-2526410
+Node: ARGC and ARGV526466
+Node: Pattern Action Summary530905
+Node: Arrays533521
+Node: Array Basics534898
+Node: Array Intro535748
+Ref: figure-array-elements537764
+Ref: Array Intro-Footnote-1540633
+Node: Reference to Elements540765
+Node: Assigning Elements543287
+Node: Array Example543782
+Node: Scanning an Array545751
+Node: Controlling Scanning548848
+Ref: Controlling Scanning-Footnote-1555494
+Node: Numeric Array Subscripts555818
+Node: Uninitialized Subscripts558092
+Node: Delete559771
+Ref: Delete-Footnote-1562585
+Node: Multidimensional562642
+Node: Multiscanning565847
+Node: Arrays of Arrays567519
+Node: Arrays Summary572419
+Node: Functions574608
+Node: Built-in575668
+Node: Calling Built-in576857
+Node: Boolean Functions578904
+Node: Numeric Functions579474
+Ref: Numeric Functions-Footnote-1583667
+Ref: Numeric Functions-Footnote-2584351
+Ref: Numeric Functions-Footnote-3584403
+Node: String Functions584679
+Ref: String Functions-Footnote-1610910
+Ref: String Functions-Footnote-2611044
+Ref: String Functions-Footnote-3611304
+Node: Gory Details611391
+Ref: table-sub-escapes613298
+Ref: table-sub-proposed614944
+Ref: table-posix-sub616454
+Ref: table-gensub-escapes618142
+Ref: Gory Details-Footnote-1619076
+Node: I/O Functions619230
+Ref: table-system-return-values625917
+Ref: I/O Functions-Footnote-1628088
+Ref: I/O Functions-Footnote-2628236
+Node: Time Functions628356
+Ref: Time Functions-Footnote-1639512
+Ref: Time Functions-Footnote-2639588
+Ref: Time Functions-Footnote-3639750
+Ref: Time Functions-Footnote-4639861
+Ref: Time Functions-Footnote-5639979
+Ref: Time Functions-Footnote-6640214
+Node: Bitwise Functions640496
+Ref: table-bitwise-ops641098
+Ref: Bitwise Functions-Footnote-1647352
+Ref: Bitwise Functions-Footnote-2647531
+Node: Type Functions647728
+Node: I18N Functions651321
+Node: User-defined653064
+Node: Definition Syntax653884
+Ref: Definition Syntax-Footnote-1659712
+Node: Function Example659789
+Ref: Function Example-Footnote-1662768
+Node: Function Calling662790
+Node: Calling A Function663384
+Node: Variable Scope664354
+Node: Pass By Value/Reference667408
+Node: Function Caveats670140
+Ref: Function Caveats-Footnote-1672235
+Node: Return Statement672359
+Node: Dynamic Typing675414
+Node: Indirect Calls677806
+Node: Functions Summary688965
+Node: Library Functions691742
+Ref: Library Functions-Footnote-1695290
+Ref: Library Functions-Footnote-2695433
+Node: Library Names695608
+Ref: Library Names-Footnote-1699402
+Ref: Library Names-Footnote-2699629
+Node: General Functions699725
+Node: Strtonum Function700995
+Node: Assert Function704077
+Node: Round Function707529
+Node: Cliff Random Function709107
+Node: Ordinal Functions710140
+Ref: Ordinal Functions-Footnote-1713249
+Ref: Ordinal Functions-Footnote-2713501
+Node: Join Function713715
+Ref: Join Function-Footnote-1715518
+Node: Getlocaltime Function715722
+Node: Readfile Function719496
+Node: Shell Quoting721525
+Node: Isnumeric Function722981
+Node: To CSV Function724417
+Node: Data File Management726493
+Node: Filetrans Function727125
+Node: Rewind Function731419
+Node: File Checking733398
+Ref: File Checking-Footnote-1734770
+Node: Empty Files734977
+Node: Ignoring Assigns737044
+Node: Getopt Function738618
+Ref: Getopt Function-Footnote-1754452
+Node: Passwd Functions754664
+Ref: Passwd Functions-Footnote-1763846
+Node: Group Functions763934
+Ref: Group Functions-Footnote-1772072
+Node: Walking Arrays772285
+Node: Library Functions Summary775333
+Node: Library Exercises776757
+Node: Sample Programs777244
+Node: Running Examples778026
+Node: Clones778778
+Node: Cut Program780050
+Node: Egrep Program790491
+Node: Id Program799808
+Node: Split Program809922
+Ref: Split Program-Footnote-1820157
+Node: Tee Program820344
+Node: Uniq Program823253
+Node: Wc Program831118
+Node: Bytes vs. Characters831513
+Node: Using extensions833115
+Node: wc program833895
+Node: Miscellaneous Programs838901
+Node: Dupword Program840130
+Node: Alarm Program842193
+Node: Translate Program847106
+Ref: Translate Program-Footnote-1851847
+Node: Labels Program852125
+Ref: Labels Program-Footnote-1855566
+Node: Word Sorting855658
+Node: History Sorting859852
+Node: Extract Program862127
+Node: Simple Sed870396
+Node: Igawk Program873612
+Ref: Igawk Program-Footnote-1888859
+Ref: Igawk Program-Footnote-2889065
+Ref: Igawk Program-Footnote-3889195
+Node: Anagram Program889322
+Node: Signature Program892418
+Node: Programs Summary893670
+Node: Programs Exercises894928
+Ref: Programs Exercises-Footnote-1899244
+Node: Advanced Features899330
+Node: Nondecimal Data901824
+Node: Boolean Typed Values903454
+Node: Array Sorting905429
+Node: Controlling Array Traversal906158
+Ref: Controlling Array Traversal-Footnote-1914665
+Node: Array Sorting Functions914787
+Ref: Array Sorting Functions-Footnote-1920906
+Node: Two-way I/O921114
+Ref: Two-way I/O-Footnote-1929109
+Ref: Two-way I/O-Footnote-2929300
+Node: TCP/IP Networking929382
+Node: Profiling932562
+Node: Persistent Memory942272
+Ref: Persistent Memory-Footnote-1951230
+Node: Extension Philosophy951361
+Node: Advanced Features Summary952896
+Node: Internationalization955166
+Node: I18N and L10N956872
+Node: Explaining gettext957567
+Ref: Explaining gettext-Footnote-1963720
+Ref: Explaining gettext-Footnote-2963915
+Node: Programmer i18n964080
+Ref: Programmer i18n-Footnote-1969193
+Node: Translator i18n969242
+Node: String Extraction970078
+Ref: String Extraction-Footnote-1971256
+Node: Printf Ordering971354
+Ref: Printf Ordering-Footnote-1974216
+Node: I18N Portability974284
+Ref: I18N Portability-Footnote-1976858
+Node: I18N Example976929
+Ref: I18N Example-Footnote-1980329
+Ref: I18N Example-Footnote-2980405
+Node: Gawk I18N980522
+Node: I18N Summary981178
+Node: Debugger982579
+Node: Debugging983603
+Node: Debugging Concepts984052
+Node: Debugging Terms985878
+Node: Awk Debugging988491
+Ref: Awk Debugging-Footnote-1989468
+Node: Sample Debugging Session989608
+Node: Debugger Invocation990160
+Node: Finding The Bug991789
+Node: List of Debugger Commands998475
+Node: Breakpoint Control999852
+Node: Debugger Execution Control1003684
+Node: Viewing And Changing Data1007164
+Node: Execution Stack1010902
+Node: Debugger Info1012583
+Node: Miscellaneous Debugger Commands1016882
+Node: Readline Support1022135
+Node: Limitations1023081
+Node: Debugging Summary1025725
+Node: Namespaces1027028
+Node: Global Namespace1028155
+Node: Qualified Names1029600
+Node: Default Namespace1030635
+Node: Changing The Namespace1031410
+Node: Naming Rules1033104
+Node: Internal Name Management1035019
+Node: Namespace Example1036089
+Node: Namespace And Features1038672
+Node: Namespace Summary1040129
+Node: Arbitrary Precision Arithmetic1041642
+Node: Computer Arithmetic1043161
+Ref: table-numeric-ranges1046978
+Ref: table-floating-point-ranges1047476
+Ref: Computer Arithmetic-Footnote-11048135
+Node: Math Definitions1048194
+Ref: table-ieee-formats1051239
+Node: MPFR features1051813
+Node: MPFR On Parole1052266
+Ref: MPFR On Parole-Footnote-11053110
+Node: MPFR Intro1053269
+Node: FP Math Caution1054959
+Ref: FP Math Caution-Footnote-11056033
+Node: Inexactness of computations1056410
+Node: Inexact representation1057441
+Node: Comparing FP Values1058824
+Node: Errors accumulate1060082
+Node: Strange values1061549
+Ref: Strange values-Footnote-11064215
+Node: Getting Accuracy1064320
+Node: Try To Round1067057
+Node: Setting precision1067964
+Ref: table-predefined-precision-strings1068669
+Node: Setting the rounding mode1070554
+Ref: table-gawk-rounding-modes1070936
+Ref: Setting the rounding mode-Footnote-11074994
+Node: Arbitrary Precision Integers1075177
+Ref: Arbitrary Precision Integers-Footnote-11078389
+Node: Checking for MPFR1078545
+Node: POSIX Floating Point Problems1080035
+Ref: POSIX Floating Point Problems-Footnote-11084899
+Node: Floating point summary1084937
+Node: Dynamic Extensions1087201
+Node: Extension Intro1088800
+Node: Plugin License1090108
+Node: Extension Mechanism Outline1090921
+Ref: figure-load-extension1091372
+Ref: figure-register-new-function1092957
+Ref: figure-call-new-function1094067
+Node: Extension API Description1096191
+Node: Extension API Functions Introduction1097920
+Ref: table-api-std-headers1099818
+Node: General Data Types1104282
+Ref: General Data Types-Footnote-11113450
+Node: Memory Allocation Functions1113765
+Ref: Memory Allocation Functions-Footnote-11118490
+Node: Constructor Functions1118589
+Node: API Ownership of MPFR and GMP Values1122494
+Node: Registration Functions1124055
+Node: Extension Functions1124759
+Node: Exit Callback Functions1130335
+Node: Extension Version String1131654
+Node: Input Parsers1132349
+Node: Output Wrappers1146993
+Node: Two-way processors1151841
+Node: Printing Messages1154202
+Ref: Printing Messages-Footnote-11155416
+Node: Updating ERRNO1155571
+Node: Requesting Values1156370
+Ref: table-value-types-returned1157123
+Node: Accessing Parameters1158232
+Node: Symbol Table Access1159516
+Node: Symbol table by name1160032
+Ref: Symbol table by name-Footnote-11163243
+Node: Symbol table by cookie1163375
+Ref: Symbol table by cookie-Footnote-11167656
+Node: Cached values1167720
+Ref: Cached values-Footnote-11171364
+Node: Array Manipulation1171521
+Ref: Array Manipulation-Footnote-11172624
+Node: Array Data Types1172661
+Ref: Array Data Types-Footnote-11175483
+Node: Array Functions1175583
+Node: Flattening Arrays1180612
+Node: Creating Arrays1187664
+Node: Redirection API1192514
+Node: Extension API Variables1195535
+Node: Extension Versioning1196260
+Ref: gawk-api-version1196697
+Node: Extension GMP/MPFR Versioning1198485
+Node: Extension API Informational Variables1200191
+Node: Extension API Boilerplate1201352
+Node: Changes from API V11205488
+Node: Finding Extensions1207122
+Node: Extension Example1207697
+Node: Internal File Description1208521
+Node: Internal File Ops1212845
+Ref: Internal File Ops-Footnote-11224403
+Node: Using Internal File Ops1224551
+Ref: Using Internal File Ops-Footnote-11226982
+Node: Extension Samples1227260
+Node: Extension Sample File Functions1228829
+Node: Extension Sample Fnmatch1236967
+Node: Extension Sample Fork1238562
+Node: Extension Sample Inplace1239838
+Node: Extension Sample Ord1243510
+Node: Extension Sample Readdir1244386
+Ref: table-readdir-file-types1245283
+Node: Extension Sample Revout1246421
+Node: Extension Sample Rev2way1247018
+Node: Extension Sample Read write array1247770
+Node: Extension Sample Readfile1251044
+Node: Extension Sample Time1252175
+Node: Extension Sample API Tests1254465
+Node: gawkextlib1254973
+Node: Extension summary1258009
+Node: Extension Exercises1261867
+Node: Language History1263145
+Node: V7/SVR3.11264859
+Node: SVR41267209
+Node: POSIX1268741
+Node: BTL1270166
+Node: POSIX/GNU1270935
+Node: Feature History1277466
+Node: Common Extensions1297033
+Node: Ranges and Locales1298510
+Ref: Ranges and Locales-Footnote-11303311
+Ref: Ranges and Locales-Footnote-21303338
+Ref: Ranges and Locales-Footnote-31303577
+Node: Contributors1303800
+Node: History summary1310005
+Node: Installation1311451
+Node: Gawk Distribution1312415
+Node: Getting1312907
+Node: Extracting1313906
+Node: Distribution contents1315618
+Node: Unix Installation1323698
+Node: Quick Installation1324520
+Node: Compiling with MPFR1327066
+Node: Shell Startup Files1327772
+Node: Additional Configuration Options1328929
+Node: Configuration Philosophy1331316
+Node: Compiling from Git1333818
+Node: Building the Documentation1334377
+Node: Non-Unix Installation1335789
+Node: PC Installation1336265
+Node: PC Binary Installation1337138
+Node: PC Compiling1338043
+Node: PC Using1339221
+Node: Cygwin1342949
+Node: MSYS1344205
+Node: OpenVMS Installation1344837
+Node: OpenVMS Compilation1345518
+Ref: OpenVMS Compilation-Footnote-11347001
+Node: OpenVMS Dynamic Extensions1347063
+Node: OpenVMS Installation Details1348699
+Node: OpenVMS Running1351134
+Node: OpenVMS GNV1355271
+Node: Bugs1356026
+Node: Bug definition1356950
+Node: Bug address1360601
+Node: Usenet1364192
+Node: Performance bugs1365423
+Node: Asking for help1368441
+Node: Maintainers1370432
+Node: Other Versions1371459
+Node: Installation summary1380391
+Node: Notes1381775
+Node: Compatibility Mode1382585
+Node: Additions1383407
+Node: Accessing The Source1384352
+Node: Adding Code1385887
+Node: New Ports1393023
+Node: Derived Files1397533
+Ref: Derived Files-Footnote-11403380
+Ref: Derived Files-Footnote-21403415
+Ref: Derived Files-Footnote-31404032
+Node: Future Extensions1404146
+Node: Implementation Limitations1404818
+Node: Extension Design1406060
+Node: Old Extension Problems1407224
+Ref: Old Extension Problems-Footnote-11408800
+Node: Extension New Mechanism Goals1408861
+Ref: Extension New Mechanism Goals-Footnote-11412357
+Node: Extension Other Design Decisions1412558
+Node: Extension Future Growth1414757
+Node: Notes summary1415381
+Node: Basic Concepts1416594
+Node: Basic High Level1417279
+Ref: figure-general-flow1417561
+Ref: figure-process-flow1418268
+Ref: Basic High Level-Footnote-11421669
+Node: Basic Data Typing1421858
+Node: Glossary1425276
+Node: Copying1458398
+Node: GNU Free Documentation License1496159
+Node: Index1521482

End Tag Table
diff --git a/doc/gawk.texi b/doc/gawk.texi
index 55c99d2e..38527dca 100644
--- a/doc/gawk.texi
+++ b/doc/gawk.texi
@@ -657,8 +657,8 @@ particular records in a file and perform operations upon them.
Pipes.
* Close Return Value:: Using the return value from
@code{close()}.
-* Nonfatal:: Enabling Nonfatal Output.
* Noflush:: Speeding Up Pipe Output.
+* Nonfatal:: Enabling Nonfatal Output.
* Output Summary:: Output summary.
* Output Exercises:: Exercises.
* Values:: Constants, Variables, and Regular
@@ -840,6 +840,8 @@ particular records in a file and perform operations upon them.
shell.
* Isnumeric Function:: A function to test whether a value is
numeric.
+* To CSV Function:: A function to convert output to CSV
+ format.
* Data File Management:: Functions for managing command-line
data files.
* Filetrans Function:: A function for handling data file
@@ -22994,6 +22996,7 @@ programming use.
* Readfile Function:: A function to read an entire file at once.
* Shell Quoting:: A function to quote strings for the shell.
* Isnumeric Function:: A function to test whether a value is numeric.
+* To CSV Function:: A function to convert output to CSV format.
@end menu
@node Strtonum Function
@@ -23825,6 +23828,88 @@ the original string.
On the other hand, it uses the @code{typeof()} function
(@pxref{Type Functions}), which is specific to @command{gawk}.
+@node To CSV Function
+@subsection Producing CSV Data
+
+@cindex comma separated values (CSV) data @subentry generating CSV data
+@cindex CSV (comma separated values) data @subentry generating CSV data
+@command{gawk}'s @option{--csv} option causes @command{gawk}
+to process CSV data (@pxref{Comma Separated Fields}).
+
+But what if you have regular data that you want to output
+in CSV format? This @value{SECTION} provides functions for
+doing that.
+
+The first function, @code{tocsv()}, takes an array of data
+fields as input. The array should be indexed starting from one.
+The optional second parameter is the separator to use. If none
+is supplied, the default is a comma.
+
+The function takes care to quote fields that contain double
+quotes, newlines, or the separator character. It then builds
+up the final CSV record and returns it.
+
+@cindex @code{tocsv()} user-defined function
+@example
+@c file eg/lib/tocsv.awk
+# tocsv.awk --- convert data to CSV format
+@c endfile
+@ignore
+@c file eg/lib/tocsv.awk
+#
+# Arnold Robbins, arnold@@skeeve.com, Public Domain
+# April 2023
+@c endfile
+@end ignore
+@c file eg/lib/tocsv.awk
+
+function tocsv(fields, sep, i, j, nfields, result)
+@{
+ if (length(fields) == 0)
+ return ""
+
+ if (sep == "")
+ sep = ","
+ delete nfields
+ for (i = 1; i in fields; i++) @{
+ nfields[i] = fields[i]
+ if (nfields[i] ~ /["\n]/ || index(nfields[i], sep) != 0) @{
+ gsub(/"/, "\"\"", nfields[i]) # double up quotes
+ nfields[i] = "\"" nfields[i] "\"" # wrap in quotes
+ @}
+ @}
+
+ result = nfields[1]
+ j = length(nfields)
+ for (i = 2; i <= j; i++)
+ result = result sep nfields[i]
+
+ return result
+@}
+@c endfile
+@end example
+
+The next function, @code{tocsv_rec()} is a wrapper around
+@code{tocsv()}. Its intended use is for when you want to convert the
+current input record to CSV format. The function itself simply copies
+the fields into an array to pass to @code{tocsv()} which does the work.
+It accepts an optional separator character as its first parameter,
+which it simply passes on to @code{tocsv()}.
+
+@cindex @code{tocsv_rec()} user-defined function
+@example
+@c file eg/lib/tocsv.awk
+function tocsv_rec(sep, i, fields)
+@{
+ delete feilds
+ for (i = 1; i <= NF; i++)
+ fields[i] = $i
+
+ return tocsv(fields, sep)
+@}
+@c endfile
+@end example
+
@node Data File Management
@section @value{DDF} Management
diff --git a/doc/gawktexi.in b/doc/gawktexi.in
index 44a7d551..f80d0335 100644
--- a/doc/gawktexi.in
+++ b/doc/gawktexi.in
@@ -652,8 +652,8 @@ particular records in a file and perform operations upon them.
Pipes.
* Close Return Value:: Using the return value from
@code{close()}.
-* Nonfatal:: Enabling Nonfatal Output.
* Noflush:: Speeding Up Pipe Output.
+* Nonfatal:: Enabling Nonfatal Output.
* Output Summary:: Output summary.
* Output Exercises:: Exercises.
* Values:: Constants, Variables, and Regular
@@ -835,6 +835,8 @@ particular records in a file and perform operations upon them.
shell.
* Isnumeric Function:: A function to test whether a value is
numeric.
+* To CSV Function:: A function to convert output to CSV
+ format.
* Data File Management:: Functions for managing command-line
data files.
* Filetrans Function:: A function for handling data file
@@ -21947,6 +21949,7 @@ programming use.
* Readfile Function:: A function to read an entire file at once.
* Shell Quoting:: A function to quote strings for the shell.
* Isnumeric Function:: A function to test whether a value is numeric.
+* To CSV Function:: A function to convert output to CSV format.
@end menu
@node Strtonum Function
@@ -22778,6 +22781,88 @@ the original string.
On the other hand, it uses the @code{typeof()} function
(@pxref{Type Functions}), which is specific to @command{gawk}.
+@node To CSV Function
+@subsection Producing CSV Data
+
+@cindex comma separated values (CSV) data @subentry generating CSV data
+@cindex CSV (comma separated values) data @subentry generating CSV data
+@command{gawk}'s @option{--csv} option causes @command{gawk}
+to process CSV data (@pxref{Comma Separated Fields}).
+
+But what if you have regular data that you want to output
+in CSV format? This @value{SECTION} provides functions for
+doing that.
+
+The first function, @code{tocsv()}, takes an array of data
+fields as input. The array should be indexed starting from one.
+The optional second parameter is the separator to use. If none
+is supplied, the default is a comma.
+
+The function takes care to quote fields that contain double
+quotes, newlines, or the separator character. It then builds
+up the final CSV record and returns it.
+
+@cindex @code{tocsv()} user-defined function
+@example
+@c file eg/lib/tocsv.awk
+# tocsv.awk --- convert data to CSV format
+@c endfile
+@ignore
+@c file eg/lib/tocsv.awk
+#
+# Arnold Robbins, arnold@@skeeve.com, Public Domain
+# April 2023
+@c endfile
+@end ignore
+@c file eg/lib/tocsv.awk
+
+function tocsv(fields, sep, i, j, nfields, result)
+@{
+ if (length(fields) == 0)
+ return ""
+
+ if (sep == "")
+ sep = ","
+ delete nfields
+ for (i = 1; i in fields; i++) @{
+ nfields[i] = fields[i]
+ if (nfields[i] ~ /["\n]/ || index(nfields[i], sep) != 0) @{
+ gsub(/"/, "\"\"", nfields[i]) # double up quotes
+ nfields[i] = "\"" nfields[i] "\"" # wrap in quotes
+ @}
+ @}
+
+ result = nfields[1]
+ j = length(nfields)
+ for (i = 2; i <= j; i++)
+ result = result sep nfields[i]
+
+ return result
+@}
+@c endfile
+@end example
+
+The next function, @code{tocsv_rec()} is a wrapper around
+@code{tocsv()}. Its intended use is for when you want to convert the
+current input record to CSV format. The function itself simply copies
+the fields into an array to pass to @code{tocsv()} which does the work.
+It accepts an optional separator character as its first parameter,
+which it simply passes on to @code{tocsv()}.
+
+@cindex @code{tocsv_rec()} user-defined function
+@example
+@c file eg/lib/tocsv.awk
+function tocsv_rec(sep, i, fields)
+@{
+ delete feilds
+ for (i = 1; i <= NF; i++)
+ fields[i] = $i
+
+ return tocsv(fields, sep)
+@}
+@c endfile
+@end example
+
@node Data File Management
@section @value{DDF} Management