File: main.cpp

package info (click to toggle)
labplot 2.12.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 78,500 kB
  • sloc: cpp: 241,048; ansic: 6,324; python: 915; xml: 400; yacc: 237; sh: 221; awk: 35; makefile: 11
file content (45 lines) | stat: -rw-r--r-- 1,585 bytes parent folder | download | duplicates (2)
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
#include <iostream>

#include <QApplication>

#include "labplot.h"

int main(int argc, char* argv[]) {
	QApplication app(argc, argv);

	AsciiFilter filter;
	auto p = filter.properties();

	p.automaticSeparatorDetection = true;
	p.separator = QStringLiteral(";");
	p.headerEnabled = true;
	p.headerLine = 1;
	p.commentCharacter = QStringLiteral("#");
	p.intAsDouble = false;
	p.removeQuotes = true;
	p.dateTimeFormat = QStringLiteral("MM/dd/yyyy");

	filter.setProperties(p);

	Spreadsheet spreadsheet(QStringLiteral("test"), false);

	filter.readDataFromFile(QStringLiteral("data.txt"), &spreadsheet, AbstractFileFilter::ImportMode::Replace);

	if (!filter.lastError().isEmpty()) {
		std::cout << "Import error: " << filter.lastError().toStdString() << std::endl;
		return -1;
	}

	std::cout << "Number of columns: " << spreadsheet.columnCount() << std::endl;
	std::cout << "Number of rows: " << spreadsheet.rowCount() << std::endl;

	spreadsheet.column(0)->setColumnMode(AbstractColumn::ColumnMode::Text);
	spreadsheet.column(1)->setColumnMode(AbstractColumn::ColumnMode::Integer);
	spreadsheet.column(2)->setColumnMode(AbstractColumn::ColumnMode::Double);
	spreadsheet.column(3)->setColumnMode(AbstractColumn::ColumnMode::Day);

	std::cout << "First Name: " << spreadsheet.column(0)->textAt(1).toStdString() << std::endl;
	std::cout << "Age: " << spreadsheet.column(1)->integerAt(1) << std::endl;
	std::cout << "Height: " << spreadsheet.column(2)->doubleAt(1) << std::endl;
	std::cout << "Date of Birth: " << spreadsheet.column(3)->dateAt(1).toString().toStdString() << std::endl;
}