Overview of Delimited Strings¶
Let us get an overview of delimited strings. As part of this topic we will primarily deal with Python objects (not the data in the files).
- At times, we read the text files and the text files might contain delimited lines.
- Also, we might want to read the data from a database or a REST API into the text files. Each line might be delimited records.
- In both the scenarios, we deal with strings. The strings typically contain multiple attribute values separated by a delimiter or separator.
- Comma separated or delimited string –
|separated or delimited string –
- Tab separated or delimited string –
- Tab is special character. When we open the file, we will not see
\t, instead we see some spaces. We will see an example at a later point in time. But we use
\tto create tab delimited strings
comma_separated = '1,2013-07-25 00:00:00.0,11599,CLOSED'
pipe_separated = '1|2013-07-25 00:00:00.0|11599|CLOSED'
tab_separated = '1\t2013-07-25 00:00:00.0\t11599\tCLOSED'
1 2013-07-25 00:00:00.0 11599 CLOSED