A Beginner's Guide to C-Sharp-CH13: Parsing Tab and CSV Files (ABGC) by Tim R. Wolf
English | 17 Jun. 2017 | ASIN: B072SDQTPX | 87 Pages | PDF | 2.23 MB
English | 17 Jun. 2017 | ASIN: B072SDQTPX | 87 Pages | PDF | 2.23 MB
Chapter 13 (81 pages) Parsing TAB, CSV and Delimited lines. This chapter describes how to take-a-part a delimited file, typically a CSV, and retrieving each found value into a separate variable or cell. C-Sharp has a dedicated "Split" method for this task, but it does not properly process most files that I have seen - it lacks many features.
In this chapter, you will write your own general-purpose Split command that works around various problems. The resulting program can be placed into a general-purpose utility library and can be used in any program. This routine is what I call "robust."
Topics: Manually parsing a line; starting a search-index at -1, for-next loops with a known number of columns; shifting delimiters within a loop; last-field logic. Tab-delimited files; tabular data with an unknown number of columns; variable columns. Error processing, blank lines, etc.
Additionally, these new utilities can be added to your library – and these utilities are amazing!
Basic Phone Number Parsing and Formatting (see also Chapter 21)
CL870-ParseCSVLine - general-purpose module that can parse any line, with any delimiter.
About this series: A beginner's guide to C-Sharp programming with Microsoft's Visual Studio, 2017. A complete programming guide. Simple, step-by-step, fully illustrated. Tailored for new and novice developers. Discusses basic techniques that all programmers need to learn.
This series is sold by Chapters at a low cost. A total of 28 chapters, in three volumes. Over 1800 pages, 900 quality illustrations.
Why am I distributing by chapter? To keep the cost down and to keep each section manageable. This book acts as a reference guide. Topics are covered in great detail, with little time spent on theory. The goal of these books are to solve programming problems quickly and efficiently.
I hope you enjoy reading and studying these pages as much as I have enjoyed writing them. –TRW