need some help with sphinx latexpdf output.
Have an document version csv-table in rst file. In html looks perfect, in pdf terrible.
my table:
.. csv-table::
:header: Version, Date, Description
:widths: 15, 20, 50
34343, 02/04/2015, "| Added *httsdfsdps* support"
3434, 14/11/2014, "| Added *folsdfsdlow* parameter to *hgfhfg*"
34343, 13/05/2014, "| Added *fdsf* parameter to *dfgdfgdfgdfgfdgdfgdfgdf*"
21321, 29/10/2013, "| Added *sdfsdf* parameter to *dfgsgfds*
| Deprecated afsfsdf interface"
312321, 05/03/2013, "| Added *dsfsdfsddsfsd* parameter to *dfgdfgdfgdfgdfgdf*
| Documented *dfgdgd*"
213211, 28/02/2013, "Added *!=* operator in *fghfghfg*"
2132132, 26/02/2013, "Added *dsfsdfsdfsdfsdfsd* in *fghf*"
213219, 07/02/2013, "| Added *jsonhash* event format
| Added *filter* parameter in event connection
| Added *group* and *map* parameter to *nph-muu-sf*"
21321321, 30/01/2013, "| Added *height* parameter in *dfgdfgdfdfg*
| Added *dfgdfgdfgdf* in dfgdfgdfgdf"
HTML
PDF
Table is not full in pdf. And this style with spaces at top, bottom near text in cells. Why latex does not take size from rst?
Can i make it better? How?
Thanks for help!
I know your question has been posted for a while, but in case it is still an issue, and for posterity who may come upon this here is how I fixed this issue in an rst doc of my own. I had the same issue, but using a standard rst table drawn out explicitly like so.
+--------+--------+---------+
|Column 1|Column 2| Column 3|
+========+========+=========+
|Value |Value |Value |
+--------+--------+---------+
And so on with many cells that would show the same behavior of running over the page end. The solution was using the class: longtable argument, and then very carefully indenting the table so that the class was applied. Like so:
.. table:: Table Title
:class: longtable
+--------+--------+---------+
|Column 1|Column 2| Column 3|
+========+========+=========+
|Value |Value |Value |
+--------+--------+---------+
This when rendered in pdf would properly break the table over multiple pages. You should be able to use the same class on a csv table.
that is my solution:
this issue in my .rst document is because my table is not too long. if your table is much longer, it will switch to next pages automatically. i have 20 rows in my table. so i change one row:
+-----------+-----------+
| | |
| | |
| | |
+-----------+-----------+
to
+-----------+-----------+
| | |
+ + +
| | |
+-----------+-----------+
it will not change your table style in pdf, but actually the table become 21 rows. when my table has 30 rows. it switch to next pages automatically. but this way may be a little stupid...
The list-table directory works. Just include the longtable class.
Example:
.. list-table:: Table Name
:widths: 5 30
:header-rows: 1
:align: center
:class: longtable
* - **Column1**
- **Column 2**
* - Row1itemsforcolumn1
- Row1itemsforcolumn2
.
.
.very very long table
.
.
* - Row1itemsforcolumnn
- Row1itemsforcolumnn
This gives a clean-looking PDF output whereby the contents are continued on the next page.
Final Output
Related
Hi everyone this is simple thing to solve but could not find a way out. I want to apply ORDER BY on a name field which have leading space in some values because of that ORDER BY does not produce the desired results. So I apply TRIM in ORDER BY CLAUSE
SELECT * FROM AssetManufacturerName ORDER BY TRIM(AssetManufacturerName)
But this still does not produce desired output as shown below. Because of leading spaces Lenovo is on top. I want it to be on 2nd.
Sample Table
+-------------+----------------+
| ID | Name |
+-------------+----------------+
| 01 | ' Robert King' |
| | |
| 02 | 'Arsim Kip' |
+-------------+----------------+
I gone thorough this question but no joys. I thinks this is MYSQL version issue.
NOTE: Our Application is working on MYSQL 5.5.52.
The trim function may work as intended. I suspect it could be different character like tab.
ORDER BY TRIM(TRIM(BOTH '\t' FROM AssetManufacturerName))
db<>fiddle demo
for example I have table 'urls'
urls:
___________________________________________
| id | href |
+--------+--------------------------------|
| 1 | /a/b/c/d/e/f/g/ |
+--------+--------------------------------|
| 2 | /a/b/g/ |
+--------+--------------------------------|
| 3 | /a/c/g/ |
+--------+--------------------------------|
| 4 | /a/d/g/ |
+--------+--------------------------------|
| 5 | /a.php?code=g |
+--------+--------------------------------|
| N | anyUrlString |
+--------+--------------------------------|
I wanna select urls which have special format, for example (like ROUTE in popular PHP frameworks)
"/a/#anyparam/g"
so: WHERE href LIKE '/a/%/g'
but it also will select row with id 5, 1..
How to compose LIKE statement to I can get only URI enabled values in #anyparam ?
must be something like this /a/[%, but not ('/','?','\')]/g but what exactly?
Thanks for any proposition!
P.S. Do not propose to use regular expression (it don't use indexes)!
Can you use multiple clauses?
LIKE '/a/%/g' AND NOT LIKE '/a/%?%/g' ....
Chain some "exceptions" together, attacking cases that do not match. It's hard to come up with a general case, with your limited sample set. An EXPLAIN will show if Indexes are still in use.
String and pattern taken from your code:
SELECT 1 WHERE '/a.php?code=g' LIKE '/a/%/g'
^ should not give you anything, since the string your testing doesn't end in /g, it ends with =g.
But an often overlooked ability of LIKE is negative character-classes. Unfortunately they are not variable-length, they always only represent 1 character, but you could REPEAT() them:
LIKE '/a/' + REPEAT('[^/?\]', LEN(#someVar)) + '/g'
I have a mysql table with a column that looks something like this:
| TAGS |
------
|Green |
|Blue |
|Orange|
|Blue |
|Green |
| ... |
------
Now what I want to do is output all the different tags that exist in a list, BUT every tag can only be outputted once (so e.g. 'Green stands two times in the database but can only stands one time in the list')
Hope you understand my question!
Thanks
You said "row" but do you mean a column labeled "tags" in your table?
There are two different ways:
Method 1:
SELECT DISTINCT tags FROM table_name WHERE condition;
Method 2:
SELECT tags FROM table_name WHERE condition GROUP BY tags;
They both will return a you an array where each item in the row is the tag without repeats (distinct). The main difference is that DISTINCT makes it easier to optimize (and possibly quicker).
Now, if you didn't make a typo and said that you have a row with a column that has multiple tags like:
|ROW_ID|TAGS |
| 1 |'Blue', 'Red' |
| 2 |'Red', 'Yellow' |
| 3 |'Blue', 'Black', 'Red'|
Then you'll have to do some parsing and array operations (but that's a completely different answer).
I have put a lot of effort into my database design, but I think I am
now realizing I made a major mistake.
Background: (Skip to 'Problem' if you don't need background.)
The DB supports a custom CMS layer for a website template. Users of the
template are limited to turning pages on and off, but not creating
their own 'new' pages. Further, many elements are non editable.
Therefore, if a page has a piece of text I want them to be able to edit,
I would have 'manually' assigned a static ID to it:
<h2><%= CMS.getDataItemByID(123456) %></h2>
Note: The scripting language is not relevant to this question, but the design forces
each table to have unique column names. Hence the convention of 'TableNameSingular_id'
for the primary key etc.
The scripting language would do a lookup on these tables to find the string.
mysql> SELECT * FROM CMSData WHERE CMSData_data_id = 123456;
+------------+-----------------+-----------------------------+
| CMSData_id | CMSData_data_id | CMSData_CMSDataType_type_id |
+------------+-----------------+-----------------------------+
| 1 | 123456 | 1 |
+------------+-----------------+-----------------------------+
mysql> SELECT * FROM CMSDataTypes WHERE CMSDataType_type_id = 1;
+----------------+---------------------+-----------------------+------------------------+
| CMSDataType_id | CMSDataType_type_id | CMSDataType_type_name | CMSDataType_table_name |
+----------------+---------------------+-----------------------+------------------------+
| 1 | 1 | String | CMSStrings |
+----------------+---------------------+-----------------------+------------------------+
mysql> SELECT * FROM CMSStrings WHERE CMSString_CMSData_data_id=123456;
+--------------+---------------------------+----------------------------------+
| CMSString_id | CMSString_CMSData_data_id | CMSString_string |
+--------------+--------------------------------------------------------------+
| 1 | 123456 | The answer to the universe is 42.|
+--------------+---------------------------+----------------------------------+
The rendered text would then be:
<h2>The answer to the universe is 42.</h2>
This works great for 'static' elements, such as the example above. I used the exact same
method for other data types such as file specifications, EMail Addresses, Dates, etc.
However, it fails for when I want to allow the User to dynamically generate content.
For example, there is an 'Events' page and they will be dynamically created by the
User by clicking 'Add Event' or 'Delete Event'.
An Event table will use keys to reference other tables with the following data items:
Data Item: Table:
--------------------------------------------------
Date CMSDates
Title CMSStrings (As show above)
Description CMSTexts (MySQL TEXT data type.)
--------------------------------------------------
Problem:
That means, each time an Event is created, I need to create the
following rows in the CMSData table;
+------------+-----------------+-----------------------------+
| CMSData_id | CMSData_data_id | CMSData_CMSDataType_type_id |
+------------+-----------------+-----------------------------+
| x | y | 6 | (Event)
| x+1 | y+1 | 5 | (Date)
| x+2 | y+2 | 1 | (Title)
| x+3 | y+3 | 3 | (Description)
+------------+-----------------+-----------------------------+
But, there is the problem. In MySQL, you can have only 1 AUTO INCREMENT field.
If I query for the highest value of CMSData_data_id and just add 1 to it, there
is a chance there is a race condition, and someone else grabs it first.
How is this issue typically resolved - or avoided in the first place?
Thanks,
Eric
The id should be meaningless, except to be unique. Your design should work no matter if the block of 4 ids is contiguous or not.
Redesign your implementation to add the parts separately, not as a block of 4. Doing so should simplify things overall, and improve your scalability.
What about locking the table before writing into it? This way, when you are inserting a row in the CMSData table, you can get the last id.
Other suggestion would be to not have an incremented id, but a unique generated one, like a guid or so.
Lock Tables
I have a number of files on my website that are private and pushed through php. I keep track of the downloads using a mysql database. Currently I just use a column for each file and insert a new row for every day, which is fine because I don't have many files.
However, I am going to be starting to add and remove files fairly often, and the number of files will be getting very large. As I see it I have two options:
The first is to add and remove columns for each file as they are added and removed. This would quickly lead to the table having very many columns. I am self-taught so I'm not sure, but I think that's probably a very bad thing. Adding and removing columns once there are a lot of rows sounds like a very expensive operation.
I could also create a new database with a generic 'fileID' feild, and then can add a new row every day for each file, but this would lead to a lot of rows. Also, it would be a lot of row insert operations to create tracking for the next day.
Which would be better? Or is there a third solution that I'm missing? Should I be using something other than mysql? I want something that can be queried so I can display the stats as graphs on the site.
Thank you very much for your help, and for taking the time to read.
I could also create a new database with a generic 'fileID' feild, and then can add a new row every day for each file, but this would lead to a lot of rows.
Yes, this is what you need to do — but you mean "a new table", not "a new database".
Basically you'll want a file table, which might look like this:
id | name | created_date | [other fields ...]
----+-----------+--------------+--------------------
1 | foo.txt | 2012-01-26 | ...
2 | bar.txt | 2012-01-27 | ...
and your downloads_by_day table will refer to it:
id | file_id | `date` | download_count
----+---------+------------+----------------
1 | 1 | 2012-01-27 | 17
2 | 2 | 2012-01-27 | 23
3 | 1 | 2012-01-28 | 6
4 | 2 | 2012-01-28 | 195