Easy way to create large data files?

I need a large data file for a program. Instead of typing every line by hand, is there a program that I can use to generate this text file a lot faster and easier? I need a specific format for each of the items being read. I don't want to sit here for hours making this data file.

Thanks!
What format do you want? Provide an example and let's see where that goes...
It needs to have these items:
MLS #, price, (0, 1, or 2), zip code with +4 code, name of realty company no longer than 20 characters including spaces

111111 229700 0 80501-2345 Jones Realty
222222 200000 2 80535-9213 We Sell Homes
333333 128931 0 80512-3190 AAA Realty
444444 283940 1 80531-0012 BB Realtors
555555 199999 2 80513-2918 CU Homes
666666 111111 0 80501-2345 Gundaker Realtors
777777 999999 1 80512-3190 Beautiful Homes
888888 100000 2 80531-2918 Jones Realty
999999 125930 0 80535-9213 BB Realtors
100000 135921 1 80512-3190 Beautiful Homes
100001 381957 1 80544-2850 AAA Realty
100100 103842 0 80538-9471 Gundaker Realtors
199201 193847 0 80256-3851 We Sell Homes
345678 176900 1 80513-2918 Metro Brokers
Is there a database or spreadsheet of this information already in existence that you could pull the necessary data from, if so what?
Last edited on
No, I need to make a text file with this data in it, there is no existing data. I just don't want to spend hours making all this information up if there is an easier way.
I have to leave so can't finish working on this but here is a start for what you want.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include <conio.h>
#include <cstdlib>
#include <dos.h>
#include <fstream>
#include <iostream>
#include <stdlib.h> 
#include <stdio.h> 
#include <string.h> 
#include <time.h>
#include <windows.h>

using namespace std;
string data;
int c=1;
int numcount = 0;
int loopcount=0;
int MLS = 100000;
int Price = 40000;
int ZipCode = 22222;
int ZipCodeExt = 1234;
string RCName;

void Function1()
{
cout << MLS << " ";
MLS++;
}

void Function2()
{

cout << Price << " ";
Price=Price+100+loopcount;
}

void Function3()
{
if (numcount>=2)
{
cout << numcount << " ";
numcount=0;
}
else
{
cout << numcount << " ";
numcount++;
}
}

void Function4()
{
cout << "Function 4" << " ";
}

void Function5()
{
cout << "Function 5" << " " ;
}
void Function6()
{
cout << "Function 6" << endl;
}

int main()
{
while (loopcount <=10)
{
Function1();
Function2();
Function3();
Function4();
Function5();
Function6();
loopcount ++;
}
return 0;
}
SamuelAdams, if it's possible for you to finish the program above I would really appreciate it. It will take me much longer which would be the equivalent to me typing in each line by hand.

Thanks
Watch this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
using namespace std;

class M_info
{
    public:
    int mls;
    int price;
    int number;
    string zipcode;
    string company;
};

M_info getInfo()
{
    M_info customer;

    for(;;)
    {
        cout << "Enter MLS#: ";
        cin >> customer.mls;
        cout << endl;

        if(customer.mls > 999999)
        {
            cout << "Please enter a number from 100000 - 999999." << endl;
            customer.mls = 0;
        }
        if(customer.mls < 100000)
        {
            cout << "Please enter a number from 100000 - 999999." << endl;
        }
        if(customer.mls >= 100000 && customer.mls <= 1000000)
        {
            break;
        }
    }

    for(;;)
    {
        cout << "Enter price: ";
        cin >> customer.price;
        cout << endl;

        if(customer.price < 100000)
        {
            cout << "You want to get bankrupt?." << endl;
            customer.price = 100000;
        }
        if(customer.price > 999999)
        {
            cout << "They wouldn't like being ripped off." << endl;
            customer.price = 100000;
        }
        if(customer.price >= 100000 && customer.price <= 1000000)
        {
                break;
        }
    }

    for(;;)
    {
        cout << "Enter number (0/1/2): ";
        cin >> customer.number;
        cout << endl;

        if(customer.number != 0 && customer.number != 1 && customer.number != 2)
        {
            cout << "Please enter 0, 1, or 2." << endl;
            customer.number = 0;
        }
        else
        {
            break;
        }
    }

    cout << "Enter zipcode (#####_####): ";
    cin >> customer.zipcode;
    cout << endl;


    cout << "Enter company name (name < 20 characters): ";
    cin >> customer.company;
    cout << endl;

    return customer;
}

int getAccounts(M_info account[], int nMaxSize)
{
    int index;
    for(index = 0; index < nMaxSize; index++)
    {
        char cAnswer;
        cout << "Enter another account? (Y or N): ";
        cin >> cAnswer;

        if(cAnswer != 'Y' && cAnswer != 'y')
        {
            break;
        }

        account[index] = getInfo();
    }
    return index;
}

void displayAccount(M_info customer)
{
    cout << customer.mls << " " << customer.price << " " << customer.number << " " << customer.zipcode << " " << customer.company << endl;
}

void displayAccounts(M_info customer[], int nCount)
{
    for(int index = 0;index < nCount; index++)
    {
        displayAccount(customer[index]);
    }
    cout << endl;
}

void sortAccounts(M_info customer[], int nCount)
{
    int nSwaps = 1;
    while(nSwaps != 0)
    {
        nSwaps = 0;

        for(int n = 0; n < (nCount - 1); n++)
        {
            if(customer[n].mls > customer[n+1].mls)
            {
                M_info temp = customer[n+1];
                customer[n+1] = customer [n];
                customer[n] = temp;

                nSwaps++;
            }
        }
    }
}

int main(int nNumberofArgs,char* pszArgs[])
{
    M_info customer[128];

    cout << "Welcome to the account manager.\n";
    int nCount = getAccounts(customer, 128);

    sortAccounts(customer, nCount);

    cout << "\nHere is the list sorted by " << "MLS#" << endl << endl;
    displayAccounts(customer,nCount);

    system("PAUSE");
    return 0;
}


This is my first successful attempt at playing with classes... Yay! And It works too!
I don't understand why this was necessary. It will take just as long if not longer to enter this data into the program above, as it would to type it into an Excel spreadsheet. Did you also have to develop a program that accepts this data, as a business requirement?

@greenleaf - Nice clASS!

EDIT** Ohhhh I see the MLS#'s and prices don't actually have to correlate to any REAL listing.
Last edited on
I think I could make a program that accepted the data. Do you want it?

And I don't think I could make it smaller..........
Something like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <random>
#include <ctime>
#include <string>
#include <fstream>

std::mt19937 rng( std::time(nullptr) ) ;

int random_int( int min, int max )
{ return std::uniform_int_distribution<>( min, max )(rng) ; }

std::string random_alpha( int minsz, int maxsz,
                           const std::string& alphabet )
{
    const std::size_t sz = random_int( minsz, maxsz ) ;
    const int n = alphabet.size() - 1 ;

    std::string str ;
    while( str.size() < sz ) str += alphabet[ random_int( 0, n ) ] ;

    return str ;
}

int main()
{
    const int nlines = 100000 ;

    const char* const path = "test_file.txt" ;
    const std::string alpha = "abcdefghijkl mnopqrst UVWX YZ" ;

    std::ofstream test_file(path) ;
    for( int i = 0 ; i < nlines ; ++i )
    {
       test_file << random_int(100000,999999) << ' '
                 << random_int(1000,999999) << ' '
                 << random_int(0,2) << ' '
                 << random_int(10000,99999) << '-' << random_int(1000,9999) << ' '
                 << random_alpha(5,20,alpha) << '\n' ;
    }
}
A google result for "list of companies":
http://www.sec.gov/rules/other/4-460list.htm

Simple enough to copy/paste that into a .txt and then extend JLBorges code to use that file.
Last edited on
kewl
Topic archived. No new replies allowed.