Skip to content

Commit b64f611

Browse files
committed
Merge branch 'feat/sorting' into main
Implement basic sorting of the Input.csv file.
2 parents 9cb2321 + 1a865e2 commit b64f611

6 files changed

Lines changed: 70 additions & 14 deletions

File tree

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,7 @@ bin/
33

44
# Build Artifacts
55
*.zip
6+
7+
# Backup data for testing
8+
data-backups/
9+
*.bak

README.md

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,30 @@
33
A free-format COBOL app that sorts a pre-defined file.
44

55
- Author: Ethan Kletschke
6-
- Version: `0.0.2`
6+
- Version: `0.0.3`
77
- Developed on: Windows 11
88
- License: MIT
99

10-
## Disclaimer
10+
## Instructions for Use
1111

12-
This app does nothing at the moment, except declare the files to use in the
13-
program and display `"Hello, World!"`.
12+
1. Decompress the `.zip` folder provided in the latest GitHub release of the app
13+
2. Move the `Input.csv` file in the `data/` folder into the same folder as the
14+
`.exe`.
15+
3. Run the `.exe` provided in the decompressed folder.
16+
4. Open `Output.csv` to verify that the sorting is complete.
17+
18+
## Using Your Own Data
19+
20+
Feel free to test the application with your own `.csv` files. Trying different
21+
data formats helps validate the robustness of the sorting logic and may uncover
22+
edge cases. When doing so, please adhere to the rules listed below:
23+
24+
### CSV Layout
25+
26+
The columns of the CSV have to be as follows:
27+
28+
1. 4-digit ID, including leading zeros
29+
2. User name and surname, up to 45 characters
30+
3. 3-digit age, including leading zeros
31+
32+
Do not include headers!

data/Input.csv

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
8511,Ethan Kletschke,019
2+
0739,Sabrielle De Lara,017
3+
1048,Skye Jackson,020
4+
6004,John Smith,060
5+
5338,Jackie Bell,012
6+
5360,Ethan Gardner,012
7+
8656,Elizabeth Baker,017
8+
7993,Eliza Smith,105
9+
2596,Peter Gomez,021
10+
3603,Alex Grande,092
11+
1405,Virginia Kelley,059
12+
5769,Harriett Owens,025
13+
6272,Aiden Love,048
14+
6052,Gerald Banks,020
15+
4529,Cole Park,085
16+
2696,Minerva Reyes,077
17+
6309,Maurice Lane,080
18+
9692,Herman Conner,055
19+
9422,Patrick Horton,071
20+
3199,Ida Moody,060

meta/project.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ project-meta:
1010
- COBOL (GnuCOBOL)
1111
status: Experimental
1212
license: MIT
13-
version: 0.0.2
13+
version: 0.0.3
1414

1515
build:
1616
dev-environments:

scripts/lint.cmd

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ cobc -I ../src ^
77
--free ^
88
../src/**.cob ^
99
-Wall ^
10-
-Wextra
10+
-Wextra ^
11+
-Wno-terminator
1112

1213
@REM Note: Run from the same folder as the script.

src/main.cob

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@ ENVIRONMENT DIVISION.
66
INPUT-OUTPUT SECTION.
77
FILE-CONTROL.
88
*> The file to sort
9-
SELECT Input-File ASSIGN TO "Input.txt"
9+
SELECT Input-File ASSIGN TO "Input.csv"
1010
ORGANISATION LINE SEQUENTIAL
1111
ACCESS SEQUENTIAL.
1212

13-
*> Sort work file (internal to SORT statement)
14-
SELECT Sort-File ASSIGN TO "SortWork.txt"
13+
*> Sort work file
14+
SELECT Sort-File ASSIGN TO "SortWork.csv"
1515
ORGANISATION LINE SEQUENTIAL
1616
ACCESS SEQUENTIAL.
1717

1818
*> Sort output file
19-
SELECT Out-File ASSIGN TO "Output.txt"
19+
SELECT Out-File ASSIGN TO "Output.csv"
2020
ORGANISATION LINE SEQUENTIAL
2121
ACCESS SEQUENTIAL.
2222

@@ -25,23 +25,35 @@ DATA DIVISION.
2525
FD Input-File.
2626
01 Input-Rec.
2727
05 In-UID PIC 9(4).
28-
05 In-Username PIC X(25).
28+
05 FILLER PIC X VALUE ",".
29+
05 In-Username PIC X(45).
30+
05 FILLER PIC X VALUE ",".
2931
05 In-User-Age PIC 999.
3032

3133
SD Sort-File.
3234
01 Sort-Rec.
3335
05 Sf-UID PIC 9(4).
34-
05 Sf-Username PIC X(25).
36+
05 FILLER PIC X VALUE ",".
37+
05 Sf-Username PIC X(45).
38+
05 FILLER PIC X VALUE ",".
3539
05 Sf-User-Age PIC 999.
3640

3741
FD Out-File.
3842
01 Out-Rec.
3943
05 Out-UID PIC 9(4).
40-
05 Out-Username PIC X(25).
44+
05 FILLER PIC X VALUE ",".
45+
05 Out-Username PIC X(45).
46+
05 FILLER PIC X VALUE ",".
4147
05 Out-User-Age PIC 999.
4248

4349
PROCEDURE DIVISION.
44-
DISPLAY "Hello, World!".
50+
SORT Sort-File
51+
ON ASCENDING KEY Sf-UID
52+
USING Input-File
53+
GIVING Out-File.
54+
55+
DISPLAY "File Sorted".
56+
4557
STOP RUN.
4658

4759
END PROGRAM Sorting-Files.

0 commit comments

Comments
 (0)