SlideShare a Scribd company logo
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!

More Related Content

Similar to Splitting up text

CSV File Manipulation
CSV File ManipulationCSV File Manipulation
CSV File Manipulation
primeteacher32
 
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
keeeerty
 
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
Keerty Smile
 
Python - Lecture 11
Python - Lecture 11Python - Lecture 11
Python - Lecture 11
Ravi Kiran Khareedi
 
Python and CSV Connectivity
Python and CSV ConnectivityPython and CSV Connectivity
Python and CSV Connectivity
Neeru Mittal
 
Csv file read and write
Csv file read and writeCsv 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
anilart346
 
CSV_FILES.pptx
CSV_FILES.pptxCSV_FILES.pptx
CSV_FILES.pptx
21BD1A058RSahithi
 
oops (1).pptx
oops (1).pptxoops (1).pptx
oops (1).pptx
NikhilKumar664731
 
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
MapR Technologies
 
CSV import in AtoM
CSV import in AtoMCSV import in AtoM
CSV import in AtoM
Artefactual Systems - 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
Amazon Web Services
 
Learning Cassandra NoSQL
Learning Cassandra NoSQLLearning Cassandra NoSQL
Learning Cassandra NoSQL
Pankaj Khattar
 
Csv python-project
Csv python-projectCsv python-project
Csv python-project
Rida 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 files
Kiran 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 3
NirsandhG
 

Similar to 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
 

More from 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
 

Recently uploaded

Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
Celine George
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
Fundacja Rozwoju Społeczeństwa Przedsiębiorczego
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
Col Mukteshwar Prasad
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
GeoBlogs
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 

Recently uploaded (20)

Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 

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!