Smart tables for Sphinx (reStructuredText) - python-sphinx

Are there any smart table extensions for using tables in RST?
It is too tedious to use tables with multiple columns having to type each row and column.
Especially if I want to merge or split the cells in the table as shown below:
I am trying to get the above table using flat-table. Can anyone suggest on how to get this?
.. flat-table:: Characteristics of the BLE badge
:header-rows: 1
* - Col 1
- Col 2
- Col 3
* - :rspan:`2` 0xfee7
- 0xfec7
- WRITE
* - 0xfec8
- INDICATE
* - 0xfec9
- READ
* - 0xfee0
- 0xfee1
- NOTIFY, READ, WRITE
Using the Linuxdoc extension to use the flat-tables.

First, install the linuxdoc Python package:
pip install linuxdoc
Next, add linuxdoc.rstFlatTable to the list of extensions in your Sphinx project's conf.py:
extensions = [
'linuxdoc.rstFlatTable',
]
The linuxdoc manual contains an example that features combinations of row and column spans.
The following reStructuredText produces your table:
.. flat-table:: Spanning table cells
:header-rows: 2
* - :rspan:`1` Col 1
- :rspan:`1` Col 2
- :rspan:`1` Col 3
- :cspan:`2` Col 4
* - Col 4a
- Col 4b
- Col 4c
* - 1
- 2
- 3
- 4a
- 4b
- 4c
Note that if you set header-rows option to 1, linuxdoc produces a malformed table.

Related

How to make this in laravel QueryBuilder

I want to take the max of the progress column that is ordered with a distinct column name.
For example;
progress - journey_id
0 - 90
12 - 90
89 - 90
7 - 90
the code I tried to make but I couldn't do more
$impressions = DB::table('journey_content_impression')
->where('user_id', 11)
->where('journey_id',12)
->select('journey_item_id','progress')->distinct()->get();
Finally, It should give us one row with the max number.
Also, other columns of row should be available like this,
$impressions->first()->user_id; //
Try this:
$impressions = DB::table('journey_content_impression')
->where('user_id',{id})
->where('journey_id',{j_id})
->groupBy('journey_item_id')
->get(['journey_item_id', DB::raw('MAX(progress) as progress')]);
Maybe it helps you try this
$impressions = DB::table('journey_content_impression')
->where([['user_id', 11],['journey_id',12]])
->select('journey_item_id','progress')->distinct()->get();

Magento table rate shipping - exclude some regions from shipping

I have setup a table rate shipping in Magento 1.9. I need to exclude some region from shipping.
For eg., In CSV there are 2 rows, in this format:
Country code - Region - postal - thrashhold - shipping cost
1. FR - Corsica - * - 0 - 18
2. * - * - * - 0 - 50
Currently, If I select France - Corsica in shipping calculator, then it returns shipping cost as 18, which is correct. If I select France - any other region then it shows shipping cost 50, which is not as requirement. Is it possible to restrict other regions, if I select France - any other region?
As per your CSV format condition on 2nd line is applied for all the location except FR-Corsica.You need to remove the second line then It must work as expected.
I think, I got it. I need to remove the regions from tables: directory_country_region and directory_country_region_name, then it wont give option to select other regions of France. Then the shipping can be restricted for these regions.
Only change order of rows
Example:
Country code - Region - postal - thrashhold - shipping cost
1. * - * - * - 0 - 50
2. FR - Corsica - * - 0 - 18

Can someone explain me the output of orcfiledump?

My table test_orc contains (for one partition):
col1 col2 part1
abc def 1
ghi jkl 1
mno pqr 1
koi hai 1
jo pgl 1
hai tre 1
By running
hive --orcfiledump /hive/user.db/test_orc/part1=1/000000_0
I get the following:
Structure for /hive/a0m01lf.db/test_orc/part1=1/000000_0 .
2018-02-18 22:10:24 INFO: org.apache.hadoop.hive.ql.io.orc.ReaderImpl - Reading ORC rows from /hive/a0m01lf.db/test_orc/part1=1/000000_0 with {include: null, offset: 0, length: 9223372036854775807} .
Rows: 6 .
Compression: ZLIB .
Compression size: 262144 .
Type: struct<_col0:string,_col1:string> .
Stripe Statistics:
Stripe 1:
Column 0: count: 6 .
Column 1: count: 6 min: abc max: mno sum: 17 .
Column 2: count: 6 min: def max: tre sum: 18 .
File Statistics:
Column 0: count: 6 .
Column 1: count: 6 min: abc max: mno sum: 17 .
Column 2: count: 6 min: def max: tre sum: 18 .
Stripes:
Stripe: offset: 3 data: 58 rows: 6 tail: 49 index: 67 .
Stream: column 0 section ROW_INDEX start: 3 length 9 .
Stream: column 1 section ROW_INDEX start: 12 length 29 .
Stream: column 2 section ROW_INDEX start: 41 length 29 .
Stream: column 1 section DATA start: 70 length 20 .
Stream: column 1 section LENGTH start: 90 length 12 .
Stream: column 2 section DATA start: 102 length 21 .
Stream: column 2 section LENGTH start: 123 length 5 .
Encoding column 0: DIRECT .
Encoding column 1: DIRECT_V2 .
Encoding column 2: DIRECT_V2 .
What does the part about stripes mean?
First, let's see how an ORC file looks like.
Now some keywords used in above image and also in your question!
Stripe - A chunk of data stored in ORC file. Any ORC file is divided into those chunks, called stripes, each sized 250 MB with index data, actual data and some metadata for actual data stored in that stripe.
Compression - The compression codec used to compress the data stored. ZLIB is the default for ORC.
Index Data - includes min and max values for each column and the row positions within each column. (A bit field or bloom filter could also be included.) Row index entries provide offsets that enable seeking to the right compression block and byte within a decompressed block. Note that ORC indexes are used only for the selection of stripes and row groups and not for answering queries.
Row data - Actual data. Is used in table scans.
Stripe Footer - The stripe footer contains the encoding of each column and the directory of the streams including their location. To describe each stream, ORC stores the kind of stream, the column id, and the stream’s size in bytes. The details of what is stored in each stream depends on the type and encoding of the column.
Postscript - holds compression parameters and the size of the compressed footer.
File Footer - The file footer contains a list of stripes in the file, the number of rows per stripe, and each column's data type. It also contains column-level aggregates count, min, max, and sum.
Now! Talking about your output from orcfiledump.
First is general information about your file. The name, location, compression codec, compression size etc.
Stripe statistics will list all the stripes in your ORC file and its corresponding information. You can see counts and some statistics about Integer columns like min, max, sum etc.
File statistics is similar to #2. Just for the complete file as opposed to each stripe in #2.
Last part, the Stripe section, talks about each column in your file and corresponding index info for each of it.
Also, you can use various options with orcfiledump to get "desired" results. Follows a handy guide.
// Hive version 0.11 through 0.14:
hive --orcfiledump <location-of-orc-file>
// Hive version 1.1.0 and later:
hive --orcfiledump [-d] [--rowindex <col_ids>] <location-of-orc-file>
// Hive version 1.2.0 and later:
hive --orcfiledump [-d] [-t] [--rowindex <col_ids>] <location-of-orc-file>
// Hive version 1.3.0 and later:
hive --orcfiledump [-j] [-p] [-d] [-t] [--rowindex <col_ids>] [--recover] [--skip-dump]
[--backup-path <new-path>] <location-of-orc-file-or-directory>
Follows a quick guide to the options used in the commands above.
Specifying -d in the command will cause it to dump the ORC file data
rather than the metadata (Hive 1.1.0 and later).
Specifying --rowindex with a comma separated list of column ids will
cause it to print row indexes for the specified columns, where 0 is
the top level struct containing all of the columns and 1 is the first
column id (Hive 1.1.0 and later).
Specifying -t in the command will print the timezone id of the
writer.
Specifying -j in the command will print the ORC file metadata in JSON
format. To pretty print the JSON metadata, add -p to the command.
Specifying --recover in the command will recover a corrupted ORC file
generated by Hive streaming.
Specifying --skip-dump along with --recover will perform recovery
without dumping metadata.
Specifying --backup-path with a new-path will let the recovery tool
move corrupted files to the specified backup path (default: /tmp).
is the URI of the ORC file.
is the URI of the ORC file or
directory. From Hive 1.3.0 onward, this URI can be a directory
containing ORC files.
Hope that helps!

YAML parsing - c++

I'm very new to YAML and what to parse a file I have made and verified is of correct structure. Here is the YAML:
---
DocType: DAQ Configuration File
# Creation Date: Wed Sep 21 10:34:06 2016
File Settings:
- Configuration Path: /mnt/sigma/daqengine/config/
- Configuration Name: daqengine.yaml
- Build File Path: ./bld
- Log File Path: ./log
- Record H5 Files: true
Engine Data:
- Make: EOS
- Model: M280
- Number of DAQs: 1
DAQ01 Settings:
- IP Address: 192.168.116.223
- Log DAQ Internal Temps: true
- T0 Temp. Limit: 55
- T0 Clear OTC Level Temp.: 50
- T0 Sample Averaging: 5
- T1 Temp. Limit: 60
- T1 Clear OTC Level Temp.: 55
- T1 Sample Averaging: 2
- No. Layers Used: 1
DAQ01 Layer 0 Settings:
- Model: AI-218
- Sample Rate: 50000
- Channels Used: 8
- Channel01: HF Temp
- Channel02: On-Axis PD
- Channel03: Off-Axis PD
- Channel04: X-Position
- Channel05: Y-Position
- Channel06: LDS
- Channel07: Laser Power
- Channel08: Unused
...
I need to extract the sequenced values to each key it is tagged to in C++.

Spotfire Custom Expression : Calculate (Num/Den) Percentages

I am trying to plot Num/Den type percentages using OVER. But my thoughts does not appear to translate into spotfire custom expression syntax.
Sample Input:
RecordID CustomerID DOS Age Gender Marker
9621854 854693 09/22/15 37 M D
9732721 676557 09/18/15 65 M D
9732700 676557 11/18/15 65 M N
9777003 5514882 11/25/15 53 M D
9853242 1753256 09/30/15 62 F D
9826842 1260021 09/30/15 61 M D
9897642 3375185 09/10/15 74 M N
9949185 9076035 10/02/15 52 M D
10088610 3512390 09/16/15 33 M D
10120650 41598 10/11/15 67 F N
9949185 9076035 10/02/15 52 M D
10088610 3512390 09/16/15 33 M D
10120650 41598 09/11/15 67 F N
Expected Out:
Row Labels D Cumulative_D N Cumulative_N Percentage
Sep 6 6 2 2 33.33%
Oct 2 8 1 3 37.50%
Nov 1 9 1 4 44.44%
My counts are working.
I want to take the same Cumulative_N & Cumulative_D count and plot Percentage over [Axis.X] as a line chart.
Here's what I am using:
UniqueCount(If([Marker]="N",[CustomerID])) / UniqueCount(If([Marker]="D",[CustomerID])) THEN SUM([Value]) OVER (AllPrevious([Axis.X])) as [CumulativePercent]
I understand SUM([Value]) is not the way to go. But I don't know what to use instead.
Also tried the one below as well, but did not:
UniqueCount(If([Marker]="N",[CustomerID])) OVER (AllPrevious([Axis.X])) / UniqueCount(If([Marker]="D",[CustomerID])) OVER (AllPrevious([Axis.X])) as [CumulativePercent]
Can you have a look ?
I found a way to make it work, but it may not fit your overall solution. I should mention i used Count() versus UniqueCount() so that the results would mirror your desired output.
Add a transformation to your current data table
Insert a calculated column Month([DOS]) as [TheMonth]
Set Row Identifers = [TheMonth]
Set value columns and aggregation methods to Count([CustomerID])
Set column titles to [Marker]
Leave the column name pattern as %M(%V) for %C
That will give you a new data table. Then, you can do your cumulative functions. I did them in a cross table to replicate your expected results. Insert a new cross table and set the values to:
Sum([D]), Sum([N]), Sum([D]) OVER (AllPrevious([Axis.Rows])) as [Cumulative_D],
Sum([N]) OVER (AllPrevious([Axis.Rows])) as [Cumulative_N],
Sum([N]) OVER (AllPrevious([Axis.Rows])) / Sum([D]) OVER (AllPrevious([Axis.Rows])) as [Percentage]
That should do it.
I don't know if Spotfire released a fix or based on everyone's inputs I could get the syntax right. But here is the solution that worked for me.
For Columns D & N,
COUNT([CustomerID])
For columns Cumulative_D & Cumulative_N,
Count([CustomerID]) OVER (AllPrevious([Axis.X])) where [Axis.X] is DOS(Month), Marker
For column Percentage,
Count(If([Marker]="N",[CustomerID])) OVER (AllPrevious([Axis.X])) / Count(If([Marker]="D",[CustomerID])) OVER (AllPrevious([Axis.X]))
where [Axis.X] is DOS(Month)

Resources