Skip to main content
Chemistry LibreTexts

6: Text File

  • Page ID
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)

    \( \newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\)

    ( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\)

    \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)

    \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\)

    \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)

    \( \newcommand{\Span}{\mathrm{span}}\)

    \( \newcommand{\id}{\mathrm{id}}\)

    \( \newcommand{\Span}{\mathrm{span}}\)

    \( \newcommand{\kernel}{\mathrm{null}\,}\)

    \( \newcommand{\range}{\mathrm{range}\,}\)

    \( \newcommand{\RealPart}{\mathrm{Re}}\)

    \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)

    \( \newcommand{\Argument}{\mathrm{Arg}}\)

    \( \newcommand{\norm}[1]{\| #1 \|}\)

    \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)

    \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    \( \newcommand{\vectorA}[1]{\vec{#1}}      % arrow\)

    \( \newcommand{\vectorAt}[1]{\vec{\text{#1}}}      % arrow\)

    \( \newcommand{\vectorB}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vectorC}[1]{\textbf{#1}} \)

    \( \newcommand{\vectorD}[1]{\overrightarrow{#1}} \)

    \( \newcommand{\vectorDt}[1]{\overrightarrow{\text{#1}}} \)

    \( \newcommand{\vectE}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash{\mathbf {#1}}}} \)

    \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)

    A text file is typically string characters across multiple lines.  It is like the container that holds content of the type string. A word processor uses special code to determine what fonts are used, when a new line is needed, etc.  Data can be stored in at text file and you need to use delimiters when you are at the end of a data cell, or entering a new line of data. Text files can contain data that can be read by spreadsheets and graphing programs, although the software will often need to convert the string type of data to integer or floating data types.

    Take the following list of chemicals and paste them into an Excel spreadsheet on your laptop (you can use Google Sheets or LibreCalc if you do not have Excel).

    lysergic acid diethylamide
    2-[4-(2-methylpropyl)phenyl]propanoic acid
    methyl 2-phenyl-2-piperidin-2-ylacetate

    Once you have the list, save it as a csv file

    file/save as/browse(choose where to save) and change from the default type (*.xlsx) to CSV UTF-8 (comma delimited) (*.csv).  There should be a new type of file now, and you should open it with a text editor (right click and choose notepad)

    clipboard_e09c9bde69feaba97fbe9380bd0f8fac8.pngFigure \(\PageIndex{1}\): The excel file was saved as a csv and opened with a text editor. (Belford cc 0.0)

    Not that every time a comma was read a new line started, and that the commas within the quotation mark did not trigger a new line  Each of these line represent a variable and this type of container is called a csv file, or comma separated variable.  It is very common for csv files to be transported over the internet as string, but they can be other data types.  If you pull a bunch of data into a spreadsheet and discover it is all inside of parenthesis, that means it is a string and you must convert it to a mathematical data  type befire you can not do calculations with it


    6: Text File is shared under a not declared license and was authored, remixed, and/or curated by LibreTexts.

    • Was this article helpful?