Menu
  • HOME
  • TAGS

Add blank row to MySQL query results based upon change in column value

mysql,sql,formatting

I have adapted the code found at: enter link description here which can easily be extended to include a line when parsing the data to write the .csv file. // Iinitialise FileWriter object. fileWriter = new FileWriter(fileName); // Iinitialise CSVPrinter object/ t. csvFilePrinter = new CSVPrinter(fileWriter, csvFileFormat); // Create .csv...

MySQL formatting query - Setting column Results as a Table header

mysql,table,formatting

mysql> select sc.name, COALESCE(SUM(case when `exchangeid` = 'AMS' then o.filledqty end),0) as AMS, COALESCE(SUM(case when `exchangeid` = 'BRU' then o.filledqty end),0) as BRU, COALESCE(SUM(case when `exchangeid` = 'BTE' then o.filledqty end),0) as BTE, COALESCE(SUM(case when `exchangeid` = 'CHI' then o.filledqty end),0) as CHI, COALESCE(SUM(case when `exchangeid` = 'CPH' then...

Erlang: strange output formatting

xml,file,formatting,erlang,output

That's because the runtime is unsure whether your terminal can display non-ASCII unicode. All strings are just lists of integers, and all binaries are just long strings of bits split into bytes of 8-bits. So the numbers you are seeing is the data you want to see, just the raw...

Represent a buffer efficiently as unicode string

c++,windows,string,unicode,formatting

Here are two methods I can think of: The easy one: convert each of your bytes in a UTF-16 wchar_t by summing 0x8000 to its value (i.e. you append a 0x80 byte). The efficiency is only 50% but at least you spare the base64 conversion, which would lower the efficiency...

Override Conditional Formatting with Worksheet_SelectionChange

excel,vba,events,formatting

There is no need to use ActiveCell in your Worksheet_SelectionChange event macro. That is what Target is/does. Modify your Worksheet_SelectionChange to be closer to the following. Private Sub Worksheet_SelectionChange(ByVal Target As Range) Target.Name = "mySelection" Cells.Interior.Pattern = xlNone Target.EntireRow.Interior.ColorIndex = 19 End Sub Now you will be constantly redefining a...

Formatting large numbers in C#

c#,.net,unity3d,formatting

I am using this method in my project, you can use too. Maybe there is better way, I dont know. public void KMBMaker( Text txt, double num ) { if( num < 1000 ) { double numStr = num; txt.text = numStr.ToString() + ""; } else if( num < 1000000...

Getting a key error while using a dict with TEMPLATE.format()

python,string,python-3.x,dictionary,formatting

You need to put ** in front of the dictionary argument. So, your last line would be: report.append(TEMPLATE.format(**stock)) and it should work. So your code should be: TEMPLATE = "{ticker:6s}:{shares:3d} x {price:8.2f} = {value:8.2f}" report = [] stock = {'ticker': 'AAPL', 'price': 128.75, 'value': 2575.0, 'shares': 20} report.append(TEMPLATE.format(**stock)) Related: Python...

Google Sheets - propagate column date formatting to new rows

google-apps-script,formatting,google-spreadsheet,rows,propagation

Create a function that will run when the form is submitted: Managing Triggers Manually - Google Documenation Code.gs function respondToFormSubmit() { //Format entire columns var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheet = ss.getSheets()[0]; var range = sheet.getRange("M:Y"); range.setNumberFormat('dd.mm'); }; ...

Python 2.7 Etree/lxml minimizing [duplicate]

python,xsd,formatting,lxml

Use method parameter of write method. Value on parameter if html or xml E.g. tree.write("output.xsd", method="html") Also have pretty print parameter which have value True or False e.g. tree.write("output.xsd", method="html", pretty_print=True) Have may parameters: write(self, file, encoding=None, method="xml", pretty_print=False, xml_declaration=None, with_tail=True, standalone=None, compression=0, exclusive=False, with_comments=True, inclusive_ns_prefixes=None) ...

Need help in writing this multiplication code

c,formatting,output,multiplication,spaces

Here is a simple example of how to make constant length printouts using printf: int main(void) { char a[6][7]={"1","22","333","4444","55555","666666"}; int i; int value; for(i=0;i<sizeof(a)/sizeof(a[0]);i++) { value = atoi(a[i]); printf("%07d\n", value); //with leading zeros printf("% 7d\n", value); //with spaces } getchar(); return 0; } Here is the output: ...

Can this be done with formatting strings alone?

c#,.net,vb.net,formatting,string-formatting

Can this be done with formatting strings alone? No. https://msdn.microsoft.com/en-us/library/0c899ak8%28v=vs.110%29.aspx#SectionSeparator Three sections The first section applies to positive values, the second section applies to negative values, and the third section applies to zeros. If the number to be formatted is nonzero, but becomes zero after rounding according to the format...

Excel - Conditional Formatting using time arguments

excel,date,formatting,formula,conditional-statements

Place the cell cursor to the first date in your list (here A1 for example) Select "Manage Rules"from the "Conditional Rules" dropdown icon in the dialog box select "New rule", then "Use a formula to determine which cells to format" enter formula as =A1<TODAY()-365 ... and give it a...

Customised Style not showing in pages

c#,wpf,xaml,formatting

I think the problem is caused by mixing styles for different UI elements. You should define separate Styles for TextBoxes, StackPanels etc by using the TargetType= attribute in your style. Moreover, setting a style for a Window (no experience with Page) often does not work in my experience. I revert...

Is it possible to format a Textbox for currency just in ASP NET?

asp.net,textbox,formatting,currency

You can wrap TextBox in an <asp:UpdatePanel> and add AsyncPostBackTrigger of TextChanged event. You can verify, validate and change the string from the server side using that.

TypeError: unsupported operand type(s) for %: 'int' and 'tuple' [closed]

python,formatting,raspberry-pi

The os.system() call returns an integer (the process exit code). You want to apply the % operator to the string argument, not the return value of the function. You are doing this: os.system(string) % tuple instead of os.system(string % tuple) Move those parentheses: os.system("pigs m %d w wvclr wvag 16...

highlight “partial” duplicates across entire sheet in Google Sheets using conditional formatting

formatting,duplicates,conditional,highlight,partial

Thanks to a genius over at the Google Product Support Forums named Isai Alvarado I finally have the solution... =if(C2<>"",ArrayFormula(countif(left($C$2:$Z$18,4),left(C2,4)))>1) I hope this helps anyone else trying to highlight partial duplicates across multiple columns. ...

Python's Multiplication Function

python,formatting,multiplication,presentation

You can add a dictionary with the operator descriptions: op_symbols = { add: '+', mul: '*', sub: '-', } and instead of str(op), use op_symbols[op]...

CSS table cell inputs not taking full width

html,css,formatting

Remove the intervening margin_bottom div as it breaks the relationship between table-row and table-cell. And as you can't add margin to a table-row, to add spacing between rows, add the padding to the cells instead: .full_width{width: 100%} .table{ display: table;} .table_row{display: table-row;} .table_cell{display:table-cell;padding-bottom: 18px;} .wrapper_cont{width: 48%} #cell2{padding-left: 4%} .label{display:block} <div...

Format datetime axis in highcharts?

datetime,highcharts,formatting,axis-labels

You can use the xAxis.labels.formatter function to specify exactly what you want to show as xAxis labels: labels: { formatter: function() { var date = new Date(this.value); var month = date.toDateString().substring(4,7); var day = date.getDate(); if(this.isFirst || day == 1) return day + '. ' + month; return day; }...

MySql datatype versus PHP formatting whilst not losing numeric sorting capabilities

php,mysql,types,formatting

You should not modify the data type storing these values, because you really dealing with a matter only of display logic. Internally, as long as some of them have a decimal part, all should be stored with a decimal part as a numeric type, rather than as a VARCHAR type....

Delphi 7: Formatting changes after using delete procedure

delphi,formatting,string-formatting,richedit

You extract the entire text, using the Text property, modify that string, and then replace the entire text. When you do that all the new text is given the selected formatting attributes. You need to select just the text that you wish to delete, and then delete it, all within...

How to write a large amount of columns in a formatted file

formatting,fortran,fortran90

What is plt_Dy5? I have the nagging feeling that it is an array with dimension(200), as your other plt_* vars seem to be. If that is the case, then for every write() statement, it would write out the whole 200 values of plt_Dy5 in addition to the current index values...

Is there a specific way to input characters at the beginning of a new line?

python,string,formatting

Just split the lines and concat: lines = """Hello how are you! Python is cool!""" for line in lines.splitlines(): if line: print(">" + line) else: print(line) >Hello how are you! > Python is cool! To get a new string and keep the newlines set keepends=True: new_s = "".join([">{}".format(line) if line.strip()...

Use DateTime format in a class but restrict time tokens

c#,parsing,datetime,formatting

DateTime d = new DateTime(2015, 6, 9); Console.WriteLine(d.ToString("dd MM yy")); // dd 06 15 Console.WriteLine(d.ToString("dd MMM yyyy HH mm tt")); // dd Jun 2015 HH mm tt var regex = new Regex("[yY]+|[M]+"); Console.WriteLine(regex.Replace("dd MM yy", m => d.ToString(m.Value))); Console.WriteLine(regex.Replace("dd MMM yyyy HH mm tt", m => d.ToString(m.Value))); output 09 06...

How to prefix values when templating them with rivets?

javascript,formatting,rivets.js

I think the solution to your problem is using formatters Rivets. They are like filters in AngularJS and support piping. You can define a formatter as follows: rivets.formatters.imgPath = function(value){ return '/img/uploads/' + value + '.jpeg' } Then you can use it in your markup like: rv-src="user.photo | imgPath" ...

Replacing section of python string with a designated variable

python,string,formatting

You can pass multiple key/value pairs to Python's str.format() format(format_string, *args, **kwargs) format() is the primary API method. It takes a format string and an arbitrary set of positional and keyword arguments. format() is just a wrapper that calls vformat(). Example: >>> print "Hello {foo:s} and {bar:s}".format(foo="World", bar="Foobar!") Hello World...

Altering XML file format in C#

c#,xml,formatting

It sounds like your XML is coming straight from your database, which means you need to transform it into something else based on the structure you have presently. While you could learn XSLT, you could also do this using LINQ to XML, querying the document you have parsed in order...

Scala: Better way for String Formatting to PhoneNumber and using Java's MessageFormat

scala,formatting,messageformat

Since we don't like nulls I wrapped your possibly-null value into an Option. If the option have a value I create the array from it and then pass it into the formatter. If it didn't have a value I give it the value "". val szPhoneFrmt = new MessageFormat("1 {0}{1}-{2}")...

Matplotlib shows superfluous microsecond precision on x axis ticks

datetime,matplotlib,formatting,decimal,ticker

Without a MWE its hard to know exactly, but I think you need to set the major_formatter. Assuming you have an axis object ax, you can use: from matplotlib.dates import DateFormatter, MinuteLocator ax.xaxis.set_major_locator( MinuteLocator(byminute=range(0,60,10)) ) ax.xaxis.set_major_formatter( DateFormatter('%H:%M') ) ...

How to set font-weight of a column text to bold based on another column value in Telerik Grid

telerik,formatting,conditional,client-templates

I modified my code to the following with help from the post: Telerik MVC Grid making a Column Red Color based on Other Column Value .Columns(columns => {columns.Bound(d => d.IsTrue).Width(0); columns.Bound(d => d.Name).Title("Name).Width(200).HtmlAttributes(new { style = "font-weight:normal;" }); }).CellAction(cell => { if (cell.Column.Title == "Name"){ var item = cell.DataItem; if(item.IsTrue)...

How do I convert a double into an n-character string using exponential notation?

java,string,formatting,double

If you're limiting you're exponential component to E0 to E99 (for positive exponential) and E0 to E-9 (for negative exponential), you could use a combination of DecimalFormat and Regex to format your results to be 6 characters in length. Something like: public static void main(String[] args) throws Exception { System.out.println(toSciNotation(1000123.456));...

Formatting long-form survey data in R

r,table,formatting,reshape,long-form

You can use reshape from base-r: reshape(q, v.names="response", idvar="person", timevar="qstn", direction="wide") person response.A response.B response.C 1 101 0 0 NA 3 102 1 0 NA 5 103 0 1 1 ...

Use formatting tags in XML

html,xml,xslt,tags,formatting

You shall use xsl:copy-of as the input format is the one expected for example: <xsl:template match="/"> <html> <head> <title>Title</title> </head> <body> <xsl:copy-of select="examples/example"/> </body> </html> </xsl:template> ...

Selecting parameters in String.format() [duplicate]

java,formatting

Yes. You can define the argument's index, see the Argument Index section of the API. For instance: // ┌ argument 3 (1-indexed) // | ┌ type of String // | | ┌ argument 2 // | | | ┌ type of decimal integer // | | | | ┌ argument...

Wrong column filtering for date column

javascript,sorting,formatting,filtering,tablesorter

You are seeing two things happen here: When entering a number in the filter that is not a valid date, a string comparison is done. So that is why the first row matches. Because the filter_defaultFilter for column 1 is set to use a fuzzy search filter_defaultFilter: {1: '~{query}'} a...

Proper Formatting in a listbox

vb.net,listbox,formatting

First of all ListBox arn't meant to be easily customizable. To answer your question I want to add dollar signs to my numbers, and left align them, you need to use String.PadLeft function. customerListBox.Items.Add((CStr(record.Item("CustomerName"))) & " : $" & (CStr(record.Item("YTDSales"))).PadLeft(8)) Note : I added 8 spaces in this exemple. It...

SSRS Average Time in Minutes and then Format to HH MM

sql,stored-procedures,reporting-services,formatting

You could add your own formatting function to the Report Code section: Public Function MinsToHHMM (ByVal Minutes As Decimal) Dim HourString = Floor(Minutes/60).ToString() Dim MinString = Floor(Minutes Mod 60).ToString() Return HourString.PadLeft(2, "0") & ":" & MinString.PadLeft(2, "0") End Function and then call it in the cell expression like this: =Code.MinsToHHMM(Avg(Fields!test.Duration.Value))...

Engineering notation with Haskell

haskell,floating-point,formatting,floating-point-precision,scientific-notation

After some research, I manage to get what I want. The function to get the engineering format work in a few steps : 1. Dissociate the exponent from the mantissa It's necessary to get the exponent apart of the mantissa. The function decodeFloat (provided by base) decode a floating point...

TextField formatting (padding) issue in Titanium Android

android,formatting,textfield,titanium-mobile,titanium-android

Finally, I solved it using custom theme named mytheme.xml added under platform folder--> android folder --> res folder--> values folder --> mytheme.xml In mytheme.xml : <?xml version="1.0" encoding="utf-8"?> <resources> <!-- Define a theme using the AppCompat.Light theme as a base theme --> <style name="Theme.MyTheme" parent="@style/Theme.Titanium"> <!-- For Titanium SDK 3.2.x...

Formatting number in European format with two decimals

javascript,formatting,locale,culture

When you use Number.toFixed() you obtain a string (not a number any more). For that reason, subsequent calls to .toLocaleString() launch the generic Object.toLocaleString() method that knows nothing about numbers, instead of the Number.toLocaleString() you want. Having a look at the documentation we can compose something like this (tested in...

String Formatting/Template/Regular Expressions

python,regex,string,pandas,formatting

It would be possible through two re.sub functions. >>> import re >>> s = '''SAMPLE0001 SAMPL1-0002 SAMPL3003 SAMPLE-004''' >>> print(re.sub(r'(?m)(?<=-)(?=\d{3}$)', '0', re.sub(r'(?m)(?<=^[A-Z\d]{6})(?!-)', '-', s))) SAMPLE-0001 SAMPL1-0002 SAMPL3-0003 SAMPLE-0004 Explanation: re.sub(r'(?m)(?<=^[A-Z\d]{6})(?!-)', '-', s) would be processed at first. It just places a hyphen after the 6th character from the beginning only...

How to convert html code to a string that replaces the newlines with \n and tabs with \t

javascript,html,string,formatting,markup

function format(data) { var returnStr = ""; var lines = data.split("\n"); var block = []; for (var i = 0; i < lines.length; i++) { block = lines[i].split('\t'); for (var j = 0; j < block.length; j++) { returnStr += block[j]; if (block.length>1) { returnStr += "\\t"; } };...

Powershell script to send email with list of files in a folder - formatting issue

email,powershell,formatting

This is a possible way: get all your files in an array $files = @(Get-ChildItem -Path $path -Recurse | Where-Object { !$_.PSIsContainer -and $_.CreationTime -lt $limit }) Then create the body of your email cycling through the array of files and writing a line for each one with the details...

How to dynamically set currency symbol in Excel custom format?

excel,formatting,format

Use a named style. They're on the Home tab, hiding under the colourful section where "Normal", "Bad", "Neutral" and so on can be seen. Click the drop-down belonging to this section of the ribbon. I'll assume that in this case we'll change the format named Currency down at the bottom,...

Get wordpress formatted post content without including wordpress functions

php,wordpress,formatting

The “cheap” method would be including the file wp-includes/formatting.php (and maybe others) and running your code through the desired filter functions, such as wpautop(). However, this does not guarantee that the content is formatted like your WordPress blog – especially because it won't apply the modifications made by plugins. Also,...

Bifurcate a string, removing the middle of the string instead of end

c#,.net,string,formatting

The problem is that Substring(maxCharacters/2, textLength-maxCharacters) into which you insert the ... already has the characters that you don't want to see - 456789. There's no way to fix it after that. What you should do instead is to pick the prefix and the suffix, and join them together, like...

How to make string paragraph easier to read for source code

powershell,formatting

I would do it this way: $paragraph = "This is a test to create a single-lined string, " + "but it doesn't seem to work. I would prefer " + "to make source code easier to read." ...

C++: Re-use line printed to console [duplicate]

c++,terminal,console,formatting,output

You can either print the "="s without a line break or you can use ncurses which I think also wget uses. But in my opinion ncurses is much work to do. For small Projects I recommend the simpler way....

SQl query, subquery formatting issue

sql,sql-server,formatting,result

If you don't have something like pivot available (though you should, since it looks like you're using T-SQL), you can create columns for each value, like so: select date ,sum(case pTypeCode when 'C' then 1 else null end) count_c ,sum(case pTypeCode when 'P' then 1 else null end) count_p ,sum(case...

Making LaTex Lists Wrap

formatting,latex

Strange how you want to save space in the enumeration yet add space between equations. I enjoy the current display. However, you can use a custom mylist which looks like an enumerate without alignment: \documentclass{article} \usepackage{showframe}% Just for this example \usepackage{amsfonts} \newenvironment{mylist} {\setlength{\parindent}{0pt}% No paragraph indent \setcounter{enumi}{0}% Restart enumeration at...

Display a table in MATLAB

matlab,formatting

I think you just have to transpose them. clc clear angle = (0:1:85)'; polyvals = ((1:86).^2)'; T = table(angle, polyvals) gives T = angle polyvals _____ ________ 0 1 1 4 2 9 3 16 4 25 5 36 6 49 7 64 ...

OpenOffice Calc displays only 9 numbers after decimal points, how to show more

formatting,openoffice-calc,formulas,libreoffice-calc

You can increase shown numbers after the decimal point by this: Tools -> Options -> OpenOffice.org Calc -> Calculate Set flag "Limit decimals for general number format" and set maximum number in input box (for me it's 20).

Use XSLT to convert date time to full words

xml,date,xslt,time,formatting

In XSLT 2.0, you can use the format-date(), format-time() and format-dateTime() functions to format dates and time in a variety of ways, for example: XML <input>2014-04-30T15:45:12</input> XSLT 2.0 <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> <xsl:template match="/"> <output> <xsl:value-of select="format-dateTime(input, 'The [DWwo] Day of [MNn] in the Year [YWw],...

Changing .NumberFormat based on .Value

excel,vba,formatting,format

Try (replacing CellRow and CellColumn with the desired row and column for the cell): If Cells(CellRow,CellColumn).Value >= -1 and Cells(CellRow,CellColumn).Value <= 1 then Cells(CellRow,CellColumn).NumberFormat = "[$€-2] #,##0.000" Else Cells(CellRow,CellColumn).NumberFormat = "[$€-2] #,##0.0" End If ...

How can I print decimal places, up-to the point there are not two repeating zeros?

java,floating-point,formatting

Either I misread the question or it changed while I was typing, my original answer suggesting DecimalFormat won't do what you're looking for. Regular expressions will: final String unformatted = Double.toString(6381.407812500002); final String formatted = unformatted.replaceAll("00+\\d*$", ""); System.out.println(formatted); Yields: 6381.4078125 You asked for any more than two zeroes and all...

Excel formatting with Java Apache POI

java,excel,formatting,apache-poi

I used Guava's Table as a data structure to save reinventing the wheel A few caveats; There may well be some mathematical trick with matrices or pivot tables or functional programming that may do the same job with much less code. I'm not sure if I'm using the latest and...

What does this horribly ugly (yet somehow secretly beautiful) Perl code do?

perl,formatting,deobfuscation

Passing the code to Google returns this page that explains qrpff is a Perl script created by Keith Winstein and Marc Horowitz of the MIT SIPB. It performs DeCSS in six or seven lines. The name itself is an encoding of "decss" in rot-13. See also qrpff explained....

How to convert a Rational into a “pretty” String?

haskell,formatting,rational

Here's one that I wrote a few weeks ago. You can specify the number of decimals you want (correctly rounded), or just pass Nothing in which case it will print the full precision, including marking the repeated decimals. module ShowRational where import Data.List(findIndex, splitAt) -- | Convert a 'Rational' to...

Get text from Gtk3 TextView/TextBuffer with formatting tags included in Python

python,formatting,gtk3

That's not very easy. Here is a link to some code that I once wrote to do the same thing for RTF output. You can probably adapt it to produce HTML output. If you manage to do so, I'd possibly integrate it into that library's successor. Alternatively, if you prefer...

Javadoc formatting hyperlinks

java,formatting,javadoc

You can run javadoc with the -link or -linkoffline parameter and point it to Oracle's javadoc: > javadoc -link https://docs.oracle.com/javase/8/docs/api/ src/* ...

Why is my file output overwritten?

c,file,struct,formatting

I changed a little bit your code, but I think you should use linked list as a data structure here, it's more simple and consume less memory. I made some tries and all went ok. :) Hope that help you!! #include <stdio.h> #include <stdlib.h> #include <ctype.h> typedef struct Record Record;...

Change font color for a row when the value is one specific value

formatting,ssrs-2008,bids

In order to change the color of an entire row, you would just select the entire row and choose expression under colors in the property menu, just as the article you linked described. If you want the color to change when that row has a particular value for a particular...

Simple and clean java float to string conversion

java,string,floating-point,formatting,type-conversion

System.out.println(String.format("%.1g%n", 0.9425)); System.out.println(String.format("%.1g%n", 0.9525)); System.out.println(String.format( "%.1f", 10.9125)); returns: 0.9 1 10.9 Use the third example for your case...

Hide leading 0 on CAST SELECT output either in MySQL or PHP

php,mysql,casting,formatting,decimal

This should work : SELECT team , COUNT(*) as played , REPLACE(SUM(win), '0.', '.') as wins , SUM(loss) as lost , SUM(draw) as draws , SUM(SelfScore) as ptsfor , SUM(OpponentScore) as ptsagainst , SUM((win*2 + draw)- loss) as score , CAST(SUM(win + (draw/2))/SUM(win + loss + draw) as decimal(4,3)) as...

Populate DataGridView Column With a Double forcing to 2 Decimal Places, with Sort

vb.net,sorting,datagridview,formatting

You are converting your values to string by using the legacy VB Format function: Function Format(Expression As Object, Optional Style As String = "") As String When it is converted, the other decimals are lost. Use the Format Property of the DefaultCellStyle for that column to specify the number of...

new line for String.format works on console, but in not in email

java,string,email,formatting

your content type is Content-Type: text/html; charset=us-ascii this means that \n or %n will not work as during HTML rendering spaces and new lines are ignored (at least most of them), replace new line character with <br> - this is new line in html another solution is to include your...

Copying lines from text file- remove formatting- Python

python,file,formatting,format

The issue lies in the fact that you're printing a list. You want to be printing elements of the list. So instead of print(s[2:16]) you can do: for i in range(2:17): print(s[i]) Because the sonnets seem to be evenly spaced I would also recommend removing the ifs and making a...

How to apply scales::percent or scales::percent_format() to prop.table in R to format numbers as percentages

r,formatting,plyr,percentage,crosstab

pt <- percent(c(round(prop.table(tab), 3))) dim(pt) <- dim(tab) dimnames(pt) <- dimnames(tab) This should work. c being used here for its property of turning a table or matrix into a vector. Alternative using sprintf: pt <- sprintf("%0.1f%%", prop.table(tab) * 100) dim(pt) <- dim(tab) dimnames(pt) <- dimnames(tab) If you want the table written...

How to configure Eclipse Formatter to add this. in front of class members

java,eclipse,formatting

In the Eclipse Preferences go to Java -> Code Style -> Clean Up. Create or edit an (active) profile. In the Profile Edit dialog go to the Member Accesses. Configure the settings in the Non static accesses-group as wished. In your case enable Use 'this' qualifier for field accesses and...

Show Results' line numbers using grep

linux,bash,grep,formatting,line

Run it through nl, the dedicated "number lines" tool: grep foo * | nl This obviously works for all commands, and not just grep....

Reformatting Dictionary output in python

python,csv,formatting,ordereddictionary

This will format it the way you described: First it writes a header row using the first entry in the list to figure out the names for the columns and then it writes the rest of the rows. writer = csv.writer(open('sortedcounts.csv', 'wb')) header = ['Top Calling Customers'] + list(list(sorted_counts.values())[0].keys()) writer.writerow(header)...

How to .write() two items, a zero and an iterator in Python?

python,csv,formatting,conditional-statements,writing

Use str.format: hrOut.write('0{}'.format(i)) Or remove the if/else and pad: for i in hrIn: hrOut.write("{}\n".format(i.rstrip().zfill(5))) zfill will only add a zero for your times with four characters: In [21]: "12:33".zfill(5) Out[21]: '12:33' In [22]: "2:33".zfill(5) Out[22]: '02:33' ...

Insert Excel row using format from row below, not above

c#,excel,formatting,add-on

You need to use the CopyOrigin parameter as well. sheet.Range[string.Format("{0}:{0}", row)] .EntireRow .Insert( Excel.XlInsertShiftDirection.xlShiftDown, Excel.XlInsertFormatOrigin.xlFormatFromRightOrBelow ) See here for details on Insert and that enum. It is possible to get this parameter by recording a macro. There is a small box that pops up when you insert the row to...

Formating data in HTTP POST request with PHP

php,http,post,data,formatting

I believe using http_build_query will solve this for you. Given the example, here's sample of how to use it: $args = array(array(0,1,2), array(3,4,5), array(1,2,3), array(6,6,5)); $kwargs = array( 'filename' => 'plot from api', 'fileopt' => 'overwrite' 'style' => array('type' => 'bar'), 'traces' => array(1), 'layout' => array('title' => 'experimental data'),...

XCode Formatting

xcode,formatting,keyboard-shortcuts

Is there a short cut or some quick way for Xcode to format this code Yes. Use the Editor->Structure->Re-indent command (the default keyboard equivalent is control-I). If you don't have anything selected, I think it just indents the line with the insertion point. If you select multiple lines and...

Trying to copy Formatting in all cells from one Excell sheet into another specifically keeping fill and text color using VBA

excel,excel-vba,formatting,copy-paste

The direct problem lies within the order of execution. Currently you are: Opening the workbook with the macro Opening the workbook with the data Copying the data Closing the workbook with the data Pasting the data into the workbook with the macro Saving the workbook with the macro (and now...

How to serialize a custom formatted time to/from xml in Go?

xml,go,formatting,date-formatting

Just as you'd implement json.Marshaler and json.Unmarshaler for doing this with JSON (there are many posts about that on StackOverflow and the internet); one way is to implement a custom time type that implements encoding.TextMarshaler and encoding.TextUnmarshaler. Those interfaces are used by encoding/xml when encoding items (after first checking for...

How can I style this php with divs?

php,html,css,formatting

echo("<div id="image_catalog">") line needs semicolon and escape, like this. echo("<div id=\"image_catalog\">"); also add semicolon to last line like so. echo ("</div>"); ...

Show number sign at the right side of number using cell formatting

excel,formatting,excel-formula,worksheet-function,conditional-formatting

Assuming integers only, please try a Custom Format of: 0"+";0"-";"-"; Re Edit: Select the range to be formatted (I chose N for illustration), HOME > Styles – Conditional Formatting, New Rule…, Use a formula to determine which cells to format, Format values where this formula is true: =N1=1 Format…, Number,...

Unfamiliar Javascript syntax/hack

html,formatting,script-tag,hacking

My best guess is that the script code was originally put in a CDATA section like this: <script type="text/javascript" //<![CDATA[ //]]> </script> When deleting //<![CDATA[ (which wasn't needed since it's referring to an external source file), they simply neglected to remove the final //]]....

How to format the values of a model in Marionette Backbone View before rendering?

view,formatting,typescript,rendering,marionette

By checking this link: http://derickbailey.github.io/backbone.marionette/docs/backbone.marionette.html You will find that serializeData is being used just before rendering the template So by overriding it, like below you can format the object values any way you want before rendering serializeData():any { var obj = super.serializeData(); obj.totalEnergy = Math.round(obj.totalEnergy).toFixed(0) return obj } ...

List git branches in directory using bash with formatting

git,bash,shell,ubuntu,formatting

There's no need to cd around for this. Just use something like this reset=$(tput sgr0) blue=$(tput setaf 4) for dir in directory_name_1 directory_name_2 ...; do branch=$(GIT_DIR="$dir/.git" git symbolic-ref --short HEAD) color= if [ master = "$branch" ]; then color=$blue fi printf '%s: %s%s%s\n' "${dir##/*}" "$color" "$branch" "$reset" done Use tput...

MariaDB formatting view code

mysql,linux,view,formatting,mariadb

Finally solved. HeidiSQL try to load view query from .frm file by LOAD_FILE function, which need file with read for all flag. Default creation mode db files are 0660 (and 0700 for directories). We can change it by include to start script (i.e. /etc/init.d/mysql) i.e. export UMASK=064 (which is OR...

Modifying formatters in Haskell's formatting library

haskell,formatting

Let's expand out the Format types from list :: ([Builder] -> Builder) -> Format r (a -> r) -> Format r ([a] -> r) Format r (a -> r) -> Format r ([a] -> r) Holey Builder r (a -> r) -> Holey Builder r ([a] -> r) ( (Builder...

DateTimeFormatter auto-corrects invalid (syntactically possible) calendar date

java,parsing,date,formatting,java-time

You can use a STRICT resolver style: import static java.time.format.ResolverStyle.STRICT; DateTimeFormatter dtf = DateTimeFormatter.ofPattern("M/d/uuuu").withResolverStyle(STRICT); By default, ofPattern uses a SMART resolver style which will use reasonable defaults. Note that I have used uuuu instead of yyyy, i.e. YEAR instead of YEAR_OF_ERA. Assuming you are in a Gregorian calendar system, the...

Is there analog of fmt:formatNumber in velocity like in jsp?

jsp,formatting,velocity,template-engine

You can use $numberTool.format("#0.00", $val) You should see 'org.apache.velocity.tools.generic.NumberTool' for more details. To make it working you also should add the following maven dependency: <dependency> <groupId>org.apache.velocity</groupId> <artifactId>velocity-tools</artifactId> <version>2.0</version> </dependency> and write following code: context.put("numberTool", new NumberTool()); ...

Retaining original table formatting after a 'pagebreak'

excel,excel-vba,table,formatting,page-break

Just change the page margins and the top few rows get excluded, but the manual page break is still required though!

Auto insert a standard comment header for every “newly generated java file” in eclipse

java,eclipse,formatting

From your screenshots, your configuration actually looks correct, i.e. you have ${filecomment} at the top of your pattern for "Code > New Java files" under "Preferences > Java > Code Style > Code Templates", and editing the pattern under "Comments > Files" to suit your liking. If your settings are...

Printing a dictionary without newlines?

python,dictionary,file-io,printing,formatting

The \n is a newline character. Written to a file it shows as a line break. You should remove it before printing out: print >> j, user[0].strip(), user[1].strip() Or even better, do it while turning to a list: z = [item.strip() for item in z.items()] ...

How to format code so while loop is triggered C

c,while-loop,formatting,boolean-logic

If scanf fails when reading an integer, the input buffer needs to be cleared of the character causing the failure. The scanset "%*[^\n]" scans and discards characters that are not newline. A newline is left in the input buffer but the %d format specifier will skip leading whitespace. #include <stdio.h>...