(brain dead) How do you call text files with data stored with fixed width/length ?
-
C++ Standard Template Library makes it easy plus a few pesky details even w/o help from an AI agent.
#include
#include
using namespace std;int main()
{
int lineBreakLength = 2;
int nameFieldLength = 11;
int ageFieldLength = 3;
basic_ifstream _ifstream(L"text file.txt", ios_base::binary);
char name[16]; name[nameFieldLength] = 0;
char age[8]; age[ageFieldLength] = 0;
char line_break[2];
while(!_ifstream.eof())
{
_ifstream.read(name, nameFieldLength);
_ifstream.read(age, ageFieldLength);
cout << name << ' ' << age << endl;
if(!_ifstream.eof()) _ifstream.read(line_break, lineBreakLength);
}
return 0;
}"I must have had lessons." - Reverend Jim Ignatowski / Christopher Lloyd
-
I have a text file that stores data and each data is fixed size. I know that a name fiels is 10 caracters wide , and then the age is 3 caracters wide. For example (dot represent the end of line for clarity)
Max 13 .
Suzanne 34 .
John Paul 66 .CI/CD = Continuous Impediment/Continuous Despair
Oh look, I'm using an archaic fixed length COBOL-style file format! How's that for the name? ;)
Latest Articles:
A Lightweight Thread Safe In-Memory Keyed Generic Cache Collection Service A Dynamic Where Implementation for Entity Framework -
I have a text file that stores data and each data is fixed size. I know that a name fiels is 10 caracters wide , and then the age is 3 caracters wide. For example (dot represent the end of line for clarity)
Max 13 .
Suzanne 34 .
John Paul 66 .CI/CD = Continuous Impediment/Continuous Despair
Maximilien wrote:
Max 13
Does that indicate your age? :-)
-
I have a text file that stores data and each data is fixed size. I know that a name fiels is 10 caracters wide , and then the age is 3 caracters wide. For example (dot represent the end of line for clarity)
Max 13 .
Suzanne 34 .
John Paul 66 .CI/CD = Continuous Impediment/Continuous Despair
-
C++ Standard Template Library makes it easy plus a few pesky details even w/o help from an AI agent.
#include
#include
using namespace std;int main()
{
int lineBreakLength = 2;
int nameFieldLength = 11;
int ageFieldLength = 3;
basic_ifstream _ifstream(L"text file.txt", ios_base::binary);
char name[16]; name[nameFieldLength] = 0;
char age[8]; age[ageFieldLength] = 0;
char line_break[2];
while(!_ifstream.eof())
{
_ifstream.read(name, nameFieldLength);
_ifstream.read(age, ageFieldLength);
cout << name << ' ' << age << endl;
if(!_ifstream.eof()) _ifstream.read(line_break, lineBreakLength);
}
return 0;
}"I must have had lessons." - Reverend Jim Ignatowski / Christopher Lloyd
I read it wrong at first too. But, he was asking what to call the file not how to read it. :laugh:
Jeremy Falcon
-
Oh look, I'm using an archaic fixed length COBOL-style file format! How's that for the name? ;)
Latest Articles:
A Lightweight Thread Safe In-Memory Keyed Generic Cache Collection Service A Dynamic Where Implementation for Entity FrameworkHow about we create a modern acronym for it.... FUBAR!
Fixed-length Unicode Byte Array Record
:rolleyes: :rolleyes:Jeremy Falcon
-
I'm sure they are direct descendant of punch cards. (large public sector system)
CI/CD = Continuous Impediment/Continuous Despair
-
fixed-length text files: Process fixed-length text files with mapping data flows in Azure Data Factory - Azure Data Factory | Microsoft Learn[^] Or fixed-width text Files: How to: read from fixed-width text Files - Visual Basic | Microsoft Learn[^]
thanks.
CI/CD = Continuous Impediment/Continuous Despair
-
Except for the part where identifiers starting with _ are reserved for the implementation :(
"A little song, a little dance, a little seltzer down your pants" Chuckles the clown
FWIW, we've used leading underscores to mark
private
members as part of our coding conventions since the 1990's and never had an issue.Software Zen:
delete this;
-
FWIW, we've used leading underscores to mark
private
members as part of our coding conventions since the 1990's and never had an issue.Software Zen:
delete this;
Fortunately, most implementations use a double underscore for system identifiers, so you're usually OK. But if you get strange error messages that refer to an identifier starting with an underscore, you've probably managed to collide with the compilers internals.
"A little song, a little dance, a little seltzer down your pants" Chuckles the clown
-
Fortunately, most implementations use a double underscore for system identifiers, so you're usually OK. But if you get strange error messages that refer to an identifier starting with an underscore, you've probably managed to collide with the compilers internals.
"A little song, a little dance, a little seltzer down your pants" Chuckles the clown
k5054 wrote:
you've probably managed to collide with the compilers internals
I was tearing my hair out once when I couldn't get a bit of financial code to compile - I had a variable called yield. Turns out there was a yield macro in the windows header to maintain compatibility with 16 bit windows. Sheesh.