Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
The results are in! See what nearly 90,000 developers picked as their most loved, dreaded, and desired coding languages and more in the 2019 Developer Survey.

Questions tagged [formatting]

A generic term meaning the process by which text transformed into a more meaningful or clearer output. A typical example would be the transformation of a decimal into a particular currency format with the correct number of decimal places.

-1
votes
0answers
51 views

Formatting integers with commas (12345 → 12,345)

Beginner/occasional C tinkerer here. (Reasonably comfortable with scripting languages, tend to avoid C due to its terseness, but trying to work past that.) I happened to want to insert commas into ...
4
votes
3answers
84 views

Regex match comments and quotes

UPDATE New regex - covers escaped slashes and uses lazy qualifiers: ...
0
votes
1answer
54 views

Formatting milliseconds as days, hours, minutes, and seconds [closed]

This is a function which aims to convert an amount of milliseconds to a more human-interpretable Day(s) Hour(s) Minute(s) Second(s) format: ...
5
votes
1answer
60 views

Indenting and dedenting ASP Classic code with Python

I've created a Python script that tries to properly indent and dedent ASP code. Similar to http://www.aspindent.com/ Since I've began using it I've noticed some edge cases that I hadn't anticipated. ...
2
votes
1answer
35 views

Get _m_s time format from milliseconds value

I could have any value in milliseconds like: 1040370 I must alert a specific converted time format : _m_s (ie:17m20s) Here ...
7
votes
2answers
59 views

Method for formatting a decimal number in Python using the given maximum number of digits and decimal places

The question itself should be fairly self-explanatory. My method takes in value, max_digits, and ...
1
vote
0answers
19 views

Extract and manipulate date from SharePoint and export into Google Charts

I am extracting a list of data from a SharePoint library with CSOM, then manipulating the data to give some sort of visible statistic through Google Charts. The data is a list of each parent ...
5
votes
3answers
82 views

Displaying elements of a list, in columns

I have a list of strings. I need to list them in rows and columns. Each row should not have more than "cols" number of values. Each of the values in a given row should be "step" away from the previous ...
2
votes
2answers
58 views

Adding punctuation to US and European patent numbers

I want to add custom punctuations in a given string. eg: ...
1
vote
2answers
72 views

Pretty print an object - JavaScript

I've written a function to prettify a json object, as if it were using JSON.stringify. I'm only focused on strings and other objects, nothing else. Is there a better way of doing this? perhaps using ...
3
votes
2answers
245 views

Adding thousand separator to various number types

Am making a pure .net library with helper functions (GitHub). However I wanted to have a thousand separator for all number types and here is what I am currently doing ...
1
vote
2answers
90 views

Formatting a price in Swift using an extension vs. a class

I have a price as a Double, which I should format it as a String. Should I use an extension instead of classical class to ...
3
votes
1answer
61 views

Formatting time delta

Quite often, I find myself measuring how long some part of my code takes to complete. I normally do that by storing current time using time.time() and then ...
11
votes
3answers
93 views

Simple generic auto __repr__

Preface At some point I was tired of writing & supporting __repr__ methods, so I've decided to write it once and reuse everywhere in my classes. Since I'm ...
2
votes
3answers
77 views

Printing integers with spaces between the digits

Problem: Given an integer between 1 and 32767 print the individual digits with 2 spaces between them. I am using C How To Program but this is not homework. The book has not gotten to arrays or ...
0
votes
1answer
42 views

Angular component to render currency or date values

I have an Angular component and it is just a label which renders a value and if it has an associated pipe, the output of the pipe should be rendered as value of the label. But I don't want to declare ...
5
votes
3answers
91 views

K&R C book, Exercise 1-21: Replace tabs with spaces

I'm new to C, just started reading K&R C book, and am working through exercises. This is my solution to 1-21, and as far as I tested it works. Anything that I'm doing wrong, or that it's not ...
3
votes
1answer
55 views

Polynomial implementation in Golang

I am writing a numerical analysis library in golang for which I need to implement a polynomial struct. Here is the source code: ...
4
votes
1answer
48 views

Easy to use code preparation script for CodeReview questions

We all face questions that forget to include their code. Sometimes all of it, sometimes only parts, that make the rest of the question unfortunately incomplete and therefore off-topic. What if it was ...
3
votes
1answer
121 views

Circuit builder that calculates resistance/current/voltage

I am somewhat new to programming. I've written a program that takes user input accepting voltages and resistors, and calculating total resistance/current/voltage in the circuit. I am looking for ways ...
6
votes
0answers
53 views

Prettify phone numbers

I am a java developer and I am trying to learn Go. I tried to make a simple code that take numbers from a .txt file and make print them in a prettier format. That ...
2
votes
2answers
64 views

Print a double as a decimal with a specified precision

How could I make this code more effective? ...
1
vote
1answer
40 views

Generating Image & Serving via HTTP with Go

What is does I'm reading The Go Programming Language. Below is my code for the last exercise in the first chapter, which is to create a webserver, generate an image, and serve the image via the ...
3
votes
1answer
56 views

Printing (number, uncertainty) pair in a formal way

I am trying to do an auxilliary function to print pairs of value-uncertainty in a formal way, given their name, value and uncertainty. The "technical" agreement is that "uncertainty rules", meaning ...
1
vote
2answers
78 views

Simple ES6 Truncate method for character, word, and sentence limits

Simple truncating method for characters, words, and sentences for a personal utility library I've been working on. Improvements & criticism welcomed! Especially around default param usage, as I'...
5
votes
3answers
158 views

Hex dump of a list of 16-bit numbers

This is some code which prints a hexdump of a list of 16 bit numbers, at 16 bytes distance for each, after the "print data" comment: ...
3
votes
2answers
63 views

Displaying information extracted from an HTML table

This function below (used on a timeout due to my page loading time) displays information on my site. I grab this data from my table view that I load into the page. It is launched by clicking a button ...
6
votes
0answers
57 views

Edis: Emacs driven indentation script

Motivation I recently picked up Emacs. As part of the process, I've started to configure the editor to fit my needs with Emacs Lisp. The Elisp indentation rules are still foreign to me, so I pretty ...
3
votes
1answer
114 views

Simple stringifying using << operator

Background I wrote my_length class and some code. my_length can be stringified using ...
3
votes
1answer
47 views

Superscript all numeric characters after ^ in an excel cell

I have material property entries in a cell those look something like this: cell.value="O2 Permeability [cm^3/m^2]" The goal ...
0
votes
2answers
59 views

Function that adds commas between groups of 3 digits in a string

My program contains some very large integers and uses the GMP library. The output contains integers (probably small enough to fit into int). I would like to make ...
2
votes
3answers
77 views

Printing a monthly calendar on console

This is an implementation of mine to an exercise found in the book Core Java SE 9 for the Impatient. Goal is basically to print a monthly calendar by accepting month and year information from the user....
3
votes
1answer
64 views

Table Printer excercise

I'm new to Python and I came to the following excercise: Write a function named printTable() that takes a list of lists of strings and displays it in a well-organized table with each column ...
1
vote
1answer
54 views

K&R Exercise 1-22. Fold (break) lines at specified column

Intro I'm going through the K&R book (2nd edition, ANSI C ver.) and want to get the most from it: learn (outdated) C and practice problem-solving at the same time. I believe that the author's ...
0
votes
1answer
62 views

Taking text from a file and formatting it

My code takes numbers from a large text file, then splits it to organise the spacing and to place it into a 2-dimensional array. The code is used to get data for a job scheduler that I'm building. <...
5
votes
1answer
133 views

K&R Exercise 1-21. Write a program `entab` that replaces strings of blanks with tabs

Intro I'm going through the K&R book (2nd edition, ANSI C ver.) and want to get the most from it: learn (outdated) C and practice problem-solving at the same time. I believe that the author's ...
12
votes
1answer
985 views

Pretty printing of the numpy ndarrays

Following this idea for pretty printing of numpy ndarrays, I have developed a very primitive prototype: ...
3
votes
2answers
338 views

Reformatting a date from YYYY-MM-DD to MM/DD/YYYY

In this small bit of JavaScript, a date is passed in as YYYY-MM-DD. It's formatted like this to be passed to the backend system. On the front end, we need to ...
2
votes
1answer
66 views

Printing a K-ary tree stored in level-order in an array

I am given an array that represents a k-ary tree (I am also given the branching factor "k") that is stored in level order. My task was to print the tree in level order. For example a trinary tree ...
2
votes
1answer
44 views

Justifying a string followed by a number

I started practicing on HackerRank to see how my learning is going on with Java. I wrote this code for problem which involved input having: String with maximum length of 10, followed by A 3 ...
2
votes
1answer
102 views

Java function to format seconds as minutes, hours, days

Anyone know how I write this code shorter, with modulos maybe? I also want to add weeks and years do this code, but it kind of got too long for that. Maybe there is some smart algoritm? Something in a ...
4
votes
3answers
591 views

Fancy padding of wide strings

I have a function that adds to a std::wstring some filler characters. The user gives a single filler character. They can also optionally given an initial filler ...
0
votes
1answer
44 views

Logging util with static lambda function

So again, I am a bit confused about some notes that i'am getting from my reviewer. I have some kind of utils, to print/prepare log messages. Yea, maybe I am a bit fanatic java 8 lambda guy but I think ...
1
vote
3answers
124 views

Convert integer to decimal string

I have a need to do some conversions in a loop to display the results using C++98 on Linux, which doesn't have any itoa() to complement ...
-5
votes
1answer
65 views

How to write SQL in a industry standard style [closed]

Here are the commands I ran to start setting up a database I need. ...
1
vote
2answers
93 views

Converting a String to USD

I'm working on a clientside iOS app for my school that involves students purchasing things, and I wrote a String extension for formatting a ...
2
votes
2answers
56 views

Method that receives a hexadecimal string and returns a formatted matrix of those values

This method is part of a larger project and comes after encoding ascii characters into hexadecimal values, so it assumes the parameter is always a valid hex string. ...
4
votes
2answers
117 views

Templated string formatting

This function formats a string by replacing every occurrence of '{n}' with the corresponding argument that was passed to the function where n is an index that ...
11
votes
2answers
128 views

Prettifier isn't pretty

Some context I'm implementing a self-closing pairs auto-completion feature in Rubberduck. One of the challenges is that the VBIDE API doesn't allow editing a line of code by "injecting" characters: ...
3
votes
1answer
75 views