SlideShare uma empresa Scribd logo
1 de 12
Reading in other files
•   VB can read in more than just text files
•   You can also read in CSV files
•   Comma Separated Value files
•   CSV is a way of storing data separated by
    commas
A CSV file opened in Excel
The data one, two, three, four and five would be separated
                by commas in a CSV file
Using VB to read in a CSV file
Dim fileReader As String

fileReader = My.Computer.FileSystem.ReadAllText(" Y:example.csv")

Console.WriteLine(fileReader)

Console.ReadLine()                              Notice the
                                              extension CSV
MEANWHILE IN THE MASTER CHIEF’S KITCHEN . . . .




     HOW AM I
  GONNA SPILT UP
   THAT CSV FILE!
Splitting up CSV’s by Comma
Ideally we want to spilt the CSV file up where the comma
                           exists

                                     Splitting the file
                                       every time a
                                     comma is found
Splitting up CSV’s by Comma
 We can use the split() function to split the CSV by commas




Split(aString, ",")
 The name of the                    Where we want the
string variable we                    split to occur
 want to split up
Splitting up CSV’s by Comma
We need something which is going to be able to hold these
                   separate values
Splitting up CSV’s by Comma
Dim s As String

Dim fileReader As String

fileReader = My.Computer.FileSystem.ReadAllText("example.csv")


s = fileReader
Dim fields As Array                    An Array will hold
                                        the split up CSV
fields = Split(s, ",")
Splitting up CSV’s by Comma
Dim s As String

Dim fileReader As String

fileReader = My.Computer.FileSystem.ReadAllText(" Y:example.csv")

s = fileReader
Dim fields As Array

fields = Split(s, ",")


For i = 0 To UBound(fields)
Console.WriteLine("word " & i & " " & fields(i))

Console.WriteLine("*****************************************")

Next
                               Using a for loop to write
                               the contents of the array
Splitting up CSV’s by Comma
MEANWHILE IN THE MASTER CHIEF’S KITCHEN . . . .




         PHEW!

Mais conteúdo relacionado

Semelhante a Splitting up text

Data file handling in python binary & csv files
Data file handling in python binary & csv filesData file handling in python binary & csv files
Data file handling in python binary & csv fileskeeeerty
 
Data file handling in python binary & csv files
Data file handling in python binary & csv filesData file handling in python binary & csv files
Data file handling in python binary & csv filesKeerty Smile
 
Python and CSV Connectivity
Python and CSV ConnectivityPython and CSV Connectivity
Python and CSV ConnectivityNeeru Mittal
 
1.CSV stands for commma seperated values which are applied to move.pdf
1.CSV stands for commma seperated values which are applied to move.pdf1.CSV stands for commma seperated values which are applied to move.pdf
1.CSV stands for commma seperated values which are applied to move.pdfanilart346
 
Introduction to Apache HBase, MapR Tables and Security
Introduction to Apache HBase, MapR Tables and SecurityIntroduction to Apache HBase, MapR Tables and Security
Introduction to Apache HBase, MapR Tables and SecurityMapR Technologies
 
An introduction to AWS CloudFormation - Pop-up Loft Tel Aviv
An introduction to AWS CloudFormation - Pop-up Loft Tel AvivAn introduction to AWS CloudFormation - Pop-up Loft Tel Aviv
An introduction to AWS CloudFormation - Pop-up Loft Tel AvivAmazon Web Services
 
Learning Cassandra NoSQL
Learning Cassandra NoSQLLearning Cassandra NoSQL
Learning Cassandra NoSQLPankaj Khattar
 
Csv python-project
Csv python-projectCsv python-project
Csv python-projectRida Khalid
 
Dealing with files in python specially CSV files
Dealing with files in python specially CSV filesDealing with files in python specially CSV files
Dealing with files in python specially CSV filesKiran Kumaraswamy
 
COMELEC III - Bash unit 1
COMELEC III - Bash unit 1COMELEC III - Bash unit 1
COMELEC III - Bash unit 1Binsent Ribera
 
Machine learning session 3
Machine learning session 3Machine learning session 3
Machine learning session 3NirsandhG
 

Semelhante a Splitting up text (20)

CSV File Manipulation
CSV File ManipulationCSV File Manipulation
CSV File Manipulation
 
Data file handling in python binary & csv files
Data file handling in python binary & csv filesData file handling in python binary & csv files
Data file handling in python binary & csv files
 
Data file handling in python binary & csv files
Data file handling in python binary & csv filesData file handling in python binary & csv files
Data file handling in python binary & csv files
 
Python - Lecture 11
Python - Lecture 11Python - Lecture 11
Python - Lecture 11
 
Python and CSV Connectivity
Python and CSV ConnectivityPython and CSV Connectivity
Python and CSV Connectivity
 
Csv file read and write
Csv file read and writeCsv file read and write
Csv file read and write
 
1.CSV stands for commma seperated values which are applied to move.pdf
1.CSV stands for commma seperated values which are applied to move.pdf1.CSV stands for commma seperated values which are applied to move.pdf
1.CSV stands for commma seperated values which are applied to move.pdf
 
CSV_FILES.pptx
CSV_FILES.pptxCSV_FILES.pptx
CSV_FILES.pptx
 
oops (1).pptx
oops (1).pptxoops (1).pptx
oops (1).pptx
 
Hbase
HbaseHbase
Hbase
 
Introduction to Apache HBase, MapR Tables and Security
Introduction to Apache HBase, MapR Tables and SecurityIntroduction to Apache HBase, MapR Tables and Security
Introduction to Apache HBase, MapR Tables and Security
 
CSV import in AtoM
CSV import in AtoMCSV import in AtoM
CSV import in AtoM
 
An introduction to AWS CloudFormation - Pop-up Loft Tel Aviv
An introduction to AWS CloudFormation - Pop-up Loft Tel AvivAn introduction to AWS CloudFormation - Pop-up Loft Tel Aviv
An introduction to AWS CloudFormation - Pop-up Loft Tel Aviv
 
Learning Cassandra NoSQL
Learning Cassandra NoSQLLearning Cassandra NoSQL
Learning Cassandra NoSQL
 
Csv python-project
Csv python-projectCsv python-project
Csv python-project
 
Dealing with files in python specially CSV files
Dealing with files in python specially CSV filesDealing with files in python specially CSV files
Dealing with files in python specially CSV files
 
COMELEC III - Bash unit 1
COMELEC III - Bash unit 1COMELEC III - Bash unit 1
COMELEC III - Bash unit 1
 
Machine learning session 3
Machine learning session 3Machine learning session 3
Machine learning session 3
 
HowTo_CSS
HowTo_CSSHowTo_CSS
HowTo_CSS
 
HowTo_CSS
HowTo_CSSHowTo_CSS
HowTo_CSS
 

Mais de Peter Andrews (12)

Trimming text
Trimming textTrimming text
Trimming text
 
Reading in files
Reading in filesReading in files
Reading in files
 
Is numeric
Is numericIs numeric
Is numeric
 
Arrays
ArraysArrays
Arrays
 
Loops
LoopsLoops
Loops
 
Rounding numbers
Rounding numbersRounding numbers
Rounding numbers
 
Select case
Select caseSelect case
Select case
 
If
IfIf
If
 
Collecting user input
Collecting user inputCollecting user input
Collecting user input
 
Variables
VariablesVariables
Variables
 
Hello world
Hello worldHello world
Hello world
 
Flow charts
Flow chartsFlow charts
Flow charts
 

Último

PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docxPoojaSen20
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxcallscotland1987
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docxPoojaSen20
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxAmanpreet Kaur
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...pradhanghanshyam7136
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 

Último (20)

PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 

Splitting up text

  • 1.
  • 2. Reading in other files • VB can read in more than just text files • You can also read in CSV files • Comma Separated Value files • CSV is a way of storing data separated by commas
  • 3. A CSV file opened in Excel The data one, two, three, four and five would be separated by commas in a CSV file
  • 4. Using VB to read in a CSV file Dim fileReader As String fileReader = My.Computer.FileSystem.ReadAllText(" Y:example.csv") Console.WriteLine(fileReader) Console.ReadLine() Notice the extension CSV
  • 5. MEANWHILE IN THE MASTER CHIEF’S KITCHEN . . . . HOW AM I GONNA SPILT UP THAT CSV FILE!
  • 6. Splitting up CSV’s by Comma Ideally we want to spilt the CSV file up where the comma exists Splitting the file every time a comma is found
  • 7. Splitting up CSV’s by Comma We can use the split() function to split the CSV by commas Split(aString, ",") The name of the Where we want the string variable we split to occur want to split up
  • 8. Splitting up CSV’s by Comma We need something which is going to be able to hold these separate values
  • 9. Splitting up CSV’s by Comma Dim s As String Dim fileReader As String fileReader = My.Computer.FileSystem.ReadAllText("example.csv") s = fileReader Dim fields As Array An Array will hold the split up CSV fields = Split(s, ",")
  • 10. Splitting up CSV’s by Comma Dim s As String Dim fileReader As String fileReader = My.Computer.FileSystem.ReadAllText(" Y:example.csv") s = fileReader Dim fields As Array fields = Split(s, ",") For i = 0 To UBound(fields) Console.WriteLine("word " & i & " " & fields(i)) Console.WriteLine("*****************************************") Next Using a for loop to write the contents of the array
  • 12. MEANWHILE IN THE MASTER CHIEF’S KITCHEN . . . . PHEW!