Skip to content

Commit

Permalink
Add tab separated format along with csv
Browse files Browse the repository at this point in the history
  • Loading branch information
josephna76 committed Mar 5, 2024
1 parent 9e7010f commit b097756
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,21 @@
const tasks = [];

lines.forEach((line) => {
const parts = line.split(",");
// Check for tab-separated values first, fall back to comma-separated
const delimiter = line.includes("\t") ? "\t" : ",";
const parts = line.split(delimiter);
if (parts.length >= 5) {
const [id, name, startDate, endDate, dependencies] = parts;
const [id, name, startDate, endDate, dependencies] = parts.map(
(part) => part.trim()
); // Trim each part to remove extra whitespace
tasks.push({
id: id.trim(),
name: name.trim(),
start: startDate.trim(),
end: endDate.trim(),
dependencies: dependencies.trim(),
id,
name,
start: startDate,
end: endDate,
dependencies: dependencies
? dependencies.split(" ").filter(Boolean)
: [], // Handle multiple dependencies, if present
});
}
});
Expand Down

0 comments on commit b097756

Please sign in to comment.