scheduleparser

package module
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 15, 2022 License: MIT Imports: 9 Imported by: 0

README

Schedule Parser

Go Reference GitHub go.mod Go version Go Report Card

Schedule Parser is a library for parsing pdf schedules with specific layout.

Installation

go get -u github.com/qsoulior/scheduleparser

Features

Parse file

initialDate := time.Now()

err := scheduleparser.ParseFile("input.pdf", "output.json", initialDate)
if err != nil {
  log.Fatal(err)
}
Parse bytes
initialDate := time.Now()

// os.ReadFile (as of Go 1.16) reads file and returns bytes
contents, err := os.ReadFile("input.pdf")
if err != nil {
  log.Fatal(err)
}
// or get bytes in another way 

result, err := scheduleparser.ParseBytes(contents, initialDate)
if err != nil {
  log.Fatal(err)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseBytes

func ParseBytes(contentBytes []byte, initialDate time.Time) ([]byte, error)

ParseBytes gets slice of pdf.Text from content bytes using reader.ReadBytes, parses content using parseText and returns content bytes.

func ParseFile

func ParseFile(inputPath string, outputPath string, initialDate time.Time) error

ParseFile reads slice of pdf.Text from input file using reader.ReadFile, parses content using parseText and writes content bytes to output file.

Types

type Clock added in v0.1.2

type Clock struct {
	// contains filtered or unexported fields
}

Clock contains hours and minutes values.

type Event added in v0.1.1

type Event struct {
	Title    string      `json:"title"`
	Teacher  string      `json:"teacher"`
	Type     string      `json:"type"`
	Subgroup string      `json:"subgroup"`
	Location string      `json:"location"`
	Dates    []EventDate `json:"dates"`
}

Event is retrieved from RawEvent. It is contained in output json.

type EventDate added in v0.1.2

type EventDate struct {
	Start     time.Time `json:"start"`
	End       time.Time `json:"end"`
	Frequency string    `json:"frequency"`
}

EventDate contains start/end datetime and frequency of schedule event.

func NewEventDate added in v0.1.2

func NewEventDate(start string, end string, eventTime *EventTime, frequency string) *EventDate

NewEventDate creates EventDate by start date and end date strings, adds time to date by eventTime and returns *EventDate.

type EventTime added in v0.1.2

type EventTime struct {
	// contains filtered or unexported fields
}

EventTime contains start/end Clock. It is retrieved by RawEvent position.

type RawEvent added in v0.1.2

type RawEvent struct {
	// contains filtered or unexported fields
}

RawEvent contains data, position in pdf file, and initial date to normalize event dates. It is retrieved from input pdf.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL