• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

PolyMathOrg / DataFrame / 5083108441

pending completion
5083108441

push

github

HernĂ¡n Morales Durand
Add methods to draw a scatter plot matrix of a DataFrame

11255 of 11536 relevant lines covered (97.56%)

2.93 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/DataFrame-IO/DataFrameTextWriter.class.st
1
"
2
Implements a Text writer for DataFrame contents, including setting the alignment of each cell to the left and right.
3

4
# Example
5

6
```language=Pharo
7
(DataFrameCsvReader new
8
        readFromString: 'Given$a$text$file$of$many$lines,$where$fields$within$a$line$
9
are$delineated$by$a$single$''dollar''$character,$write$a$program
10
that$aligns$each$column$of$fields$by$ensuring$that$words$in$each$
11
column$are$separated$by$at$least$one$space.
12
Further,$allow$for$each$word$in$a$column$to$be$either$left$
13
justified,$right$justified,$or$center$justified$within$its$column.'
14
        withSeparator: $$
15
        withHeader: false)
16
                writeToTextAlignedRight
17
```
18
"
19
Class {
20
        #name : #DataFrameTextWriter,
21
        #superclass : #DataFrameCsvWriter,
22
        #instVars : [
23
                'padDirection'
24
        ],
25
        #category : #'DataFrame-IO-Core'
26
}
27

28
{ #category : #accessing }
29
DataFrameTextWriter >> padDirection [
×
30

×
31
        ^ padDirection
×
32
]
×
33

34
{ #category : #accessing }
35
DataFrameTextWriter >> padDirection: anObject [
×
36

×
37
        padDirection := anObject
×
38
]
×
39

40
{ #category : #accessing }
41
DataFrameTextWriter >> padLeft [
×
42
        "Set the receiver to pad elements to left"
×
43

×
44
        self padDirection: #padLeftTo:
×
45
]
×
46

47
{ #category : #accessing }
48
DataFrameTextWriter >> padRight [
×
49
        "Set the receiver to pad elements to left"
×
50

×
51
        self padDirection: #padRightTo:
×
52
]
×
53

54
{ #category : #writing }
55
DataFrameTextWriter >> rowPairsFor: colWidths using: row [
×
56

×
57
        | gen |
×
58

×
59
        gen := Generator on: [ : g | colWidths do: [ : k | g yield: k ] ].
×
60
        ^ row collect: [ : w | { w . gen next } ]
×
61
]
×
62

63
{ #category : #writing }
64
DataFrameTextWriter >> write: aDataFrame [
×
65
        "Answer a <String> representation of aDataFrame, aligned according to the receiver's padDirection"
×
66

×
67
        ^ String streamContents: [ : stream |
×
68
                | colWidths |
×
69
                colWidths := aDataFrame applySize applyToAllColumns: #max.
×
70
                (aDataFrame collect: [ : row | self rowPairsFor: colWidths using: row ])
×
71
                        do: [ : line |
×
72
                                self writeLine: line to: stream.
×
73
                                stream cr ] ]
×
74
]
×
75

76
{ #category : #writing }
77
DataFrameTextWriter >> writeLine: line to: stream [
×
78

×
79
        line do: [ : pair |
×
80
                pair first ifNotNil: [ : pf |
×
81
                        stream
×
82
                                << (pf perform: self padDirection with: pair second);
×
83
                                space ] ]
×
84
]
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc