Questions tagged [converting]

Converting involves changing data from one data type or format to another.

Filter by
Sorted by
Tagged with
1 vote
1 answer
44 views

safe numeric type converter

I have written a function for casting between built in numeric types. I built it to check if the source value is within the range of the destination value, and to provide a nicely legible error if not....
Diederick C. Niehorster's user avatar
1 vote
1 answer
79 views

C++ arbitrary base convertor

This is my second C++ program. Again, I wrote it all by myself. I only started learning C++ yesterday. The concept of the program is simple; it should read input from ...
Ξένη Γήινος's user avatar
4 votes
2 answers
225 views

fast convert string_view to floating point

The code makes following assumptions: std::string_view is not null-terminated there are no exponents, all floating point inputs are in the way 123.123 limiting ...
Nick's user avatar
  • 1,490
1 vote
0 answers
69 views

Python script that turns a gigantic text file into an IP geolocation database

I have written a Python script that turns a gigantic text file into a SQLite3 database. The text file is truly gigantic, it is 133MiB or 140,371,572 bytes in size, and contains 140,371,572 characters ...
Ξένη Γήινος's user avatar
5 votes
1 answer
310 views

Python script that identifies the country code of a given IP address

This is a Python script I wrote to identify the country code of a given IP address, using data obtained from tor. It uses geoip.txt to identify country code for IPv4 addresses, and geoip6.txt to do so ...
Ξένη Γήινος's user avatar
5 votes
1 answer
1k views

Convert bool to int and int to bool

I'm a noob. I wrote this code to convert bools to ints and ints to bools as a past-time but I would like to know whether to continue programming - this is the kind of thing I've been doing, no useful ...
user avatar
4 votes
1 answer
159 views

Fahrenheit <=> Celsius converter in Rust

It's one of the tasks suggested in the Rust Programming Language book by Steve Klabnik and Carol Nichols, and to a complete Rust newbie like me, figuring out converting scale from ...
razorramon's user avatar
6 votes
1 answer
111 views

General bytes to number converter (c++)

I've written a bytes to number converter for cpp similar to the python int.from_bytes. It does not make any assumptions on: The endianness of the input buffer The ...
Sam Coutteau's user avatar
1 vote
1 answer
496 views

Mapping pandas' Series to dataclasses

I've got something really simple this time where I'm mapping pandas' Series to dataclasses with a oneliner helper function (as ...
t3chb0t's user avatar
  • 44.1k
2 votes
3 answers
177 views

length unit converter

I'm trying to make a imperial/metric length unit converter in Python. Here is my full code: ...
Rozy0930's user avatar
3 votes
0 answers
70 views

Type coercion function (a "safe cast")

Usually in C++, the language rules automatically convert types as necessary. For example, I can pass a pointer-to-derived in place of a pointer-to-base, and the same with references. There are ...
Toby Speight's user avatar
3 votes
1 answer
163 views

Python script copying specific table data from multiple docx files into an XLS file

The code copies the second column from the right of all the docx files' tables from the folder where the py file is saved, and does some editing on the content in specific cases. The problem that it ...
Domi Szécskai's user avatar
4 votes
1 answer
363 views

C++ String Conversions using Iconv

Since charset conversions is so darn badly implemented and most standard options are deprecated I recently wrote a wrapper around iconv that converts from system narrow / multibyte character set to ...
rioki's user avatar
  • 452
3 votes
1 answer
93 views

An up-cast for C++

Usually in C++, the language rules automatically widen types as necessary. For example, I can pass a pointer-to-derived in place of a pointer-to-base, and the same with references. There are ...
Toby Speight's user avatar
5 votes
3 answers
694 views

Number System Conversions with strtol

Description The code uses strtol() to convert text that represents a value in a given base into an integer. It takes three arguments from the command line, ...
Harith's user avatar
  • 1,231
5 votes
1 answer
210 views

Function to format time, from seconds to a particular expresion

From an integer X representing a time duration in seconds produce a simplified string representation. For example, given X=100, you should output: "1m40s" Use the following abbreviations w,d,...
Leandro Tabak's user avatar
8 votes
1 answer
216 views

Convert integer to Roman numeral string

This is my 1st time developing PHP code and I am only 13 years old. I have experience in other programming languages like lua, python, and c++. This is a simple Number to Roman Numeral code I made for ...
Red Sebastian A. Arce's user avatar
3 votes
0 answers
72 views

Convert different address formats to German one

I would like to find out which address format is input and convert it to the German format. Examples: 5, Rue de l'exemple is luxembourgish. ...
Daniel's user avatar
  • 219
1 vote
0 answers
62 views

convert GPS coordinates to C-SQUARES, resolution 0.05°×0.05°

This is a simple C-Squares encoder in R. FYI, C-Squares is a geocoding algorithm that assigns GPS coordinates to a spatial grid with a chosen resolution. Its specifications is here: https://www.cmar....
simplyPTA's user avatar
  • 181
0 votes
3 answers
157 views

Convert from decimal to binary and octal

I wrote a program that implements an algorithm that converts from decimal to binary and octal Please criticize my implementation. What else can I do to improve? ...
Mike's user avatar
  • 299
-1 votes
1 answer
2k views

Best way to convert the string with Byte sequence to Byte Array

We had a string with byte array (hexadecimal) sequence, like: ...
Igor's user avatar
  • 172
0 votes
2 answers
77 views

JSONtab library : A tool to reversibly convert between an arbitrarily deep nested object and a tabular format

Could the following code be improved in terms of clarity, performance, maintainability, best practices etc? JSONtab library A tool to reversibly convert between an arbitrarily deep nested object and a ...
user2309803's user avatar
1 vote
1 answer
590 views

Python IPv6 verifier, parser and converter

This is a simple Python 3 program that verifies whether a string is a valid IPv6 address or not, parses IPv6 address to its hexadecimal and decimal values, and converts an integer to IPv6 format. I am ...
Ξένη Γήινος's user avatar
3 votes
4 answers
371 views

Convert number 1-5 from its spelt-out form

I'm working with an API that for some strange reason returns star ratings as words, like FIVE,FOUR,THREE,TWO,ONE. As far as I can see, there's no way to just get ...
Sensanaty's user avatar
  • 175
3 votes
3 answers
555 views

Convert program arguments to std::wstring

Due to recent need I wrote a simple main function that has the goal to convert the C-style strings and arrays into a more STL-style. Then because I also had a need ...
BrainStone's user avatar
2 votes
3 answers
680 views

Convert string to integer and catch errors

I have attempted [and made one] function to convert string to integer and catch errors in pure c Working method The whole working method is present in code itself The header file The str2num.h here:- <...
Pear's user avatar
  • 77
4 votes
1 answer
920 views

Python 3 script to phonetically transliterate written English to Cyrillic and/or Greek

This is a Python 3 script I have written over three days that transliterates (not translating) English orthography written in Latin alphabet to the Cyrillic alphabet, the Greek alphabet or a mixed of ...
Ξένη Γήινος's user avatar
0 votes
2 answers
158 views

Python 3 integer seconds to date-time string convertor

I have written two functions that output a date-time string for any given non-negative integer. The integer is treated as representing total number of seconds in a given time period, the first ...
Ξένη Γήινος's user avatar
1 vote
1 answer
1k views

Python 3 arbitrary base converter and base36 encoder

This is a script that can convert any numerical value to any arbitrary radix representation and back, well, technically it can convert a number to any base, but because the output is a string ...
Ξένη Γήινος's user avatar
2 votes
1 answer
133 views

Is it good way to user dao when assembling dto to entity or not?

I have User entity that has relationship to other entities(Order,Profile) When I assemble entity from dto and back I need assemble order and profile entity too. User entity: ...
DozezQuest's user avatar
6 votes
1 answer
357 views

Assembler. Algorithm for incrementing a decimal number

I share an algorithm that I have written myself. It is useful for incrementing any digit of a decimal number. That way, a conversion to decimal is not necessary. Please excuse the mistakes. I am ...
FER31's user avatar
  • 63
2 votes
3 answers
888 views

Python binary, decimal, hexadecimal, IPv4, octal converter

This is a Python (3) script that converts numbers among 5 data formats: binary, decimal, hexadecimal and octal, it supports 16 conversions, that is, it can convert each of the five data formats to and ...
Ξένη Γήινος's user avatar
3 votes
1 answer
934 views

PowerShell script binary-decimal-hexadecimal-ipv4 convertor

This is a fully functional PowerShell script I wrote not long ago that converts data (numerical data) among 4 data formats: binary, decimal, hexadecimal and ipv4. It supports 12 conversions, it can ...
Ξένη Γήινος's user avatar
6 votes
4 answers
1k views

Bytes to binary conversion function

I created a quick function to convert n bytes into binary for my student. She is not on that level yet, but I think it would be best for her if my demonstrative ...
Edenia's user avatar
  • 1,548
6 votes
2 answers
491 views

Flatten JSON to string

The code below is a Python module to flatten JSON-like structure (nested dictionaries and lists) to a single string. It also provides partial result in the form of flat list of strings. This ...
pabouk - Ukraine stay strong's user avatar
1 vote
1 answer
90 views

convert .sav SPSS files into long or flat format CSVs

I'm a long standing PHP, JS, C#(Unity) dev looking to get outside objects and lower down. I've written a quick program to read binary data from a .sav file, and output the data section into CSV's in ...
E R Barratt's user avatar
1 vote
1 answer
149 views

Binary-Decimal-Hexadecimal converter

I'm a fairly new programmer and have been learning c++ for about 8 months now. I've written a program that can take either binary, hexadecimal, and decimal inputs and convert them to the other two ...
Axel Bozic's user avatar
2 votes
3 answers
268 views

ArrayDowncasters Implementation for Downcasting from System.Array to Array of Specific Type in C#

I am working with System.Array and I am trying to convert System.Array objects to array of specific type (such as ...
JimmyHu's user avatar
  • 3,918
3 votes
3 answers
2k views

PowerShell script to convert .reg files to PowerShell commands

This is a PowerShell script I wrote a while ago that converts Windows Registry files to PowerShell commands(New-Item, Remove-Item...
Ξένη Γήινος's user avatar
1 vote
1 answer
262 views

ConvertAll Methods Implementation for Jagged Arrays in C#

This is a follow-up question for ConvertAll Methods Implementation for Multidimensional Array in C# and ConvertAll Methods Implementation for Multidimensional Array in C# - follow-up. Besides the ...
JimmyHu's user avatar
  • 3,918
1 vote
1 answer
85 views

ConvertAll Methods Implementation for Multidimensional Array in C# - follow-up

This is a follow-up question for ConvertAll Methods Implementation for Multidimensional Array in C#. Thanks to aepot's answer and Olivier's answer. In order to match the usage of the build-in API <...
JimmyHu's user avatar
  • 3,918
9 votes
2 answers
524 views

ConvertAll Methods Implementation for Multidimensional Array in C#

I am trying to perform some conversions with multidimensional array in C# and I have checked the discussion ConvertAll and 2-dimensional arrays. I found that ...
JimmyHu's user avatar
  • 3,918
0 votes
2 answers
87 views

Format simple array in multidimensional

I have a simple array in PHP like this : ...
Lokomass's user avatar
5 votes
2 answers
3k views

Represent integer as binary in C

To practice my C, I've written a small function in C to display an integer as an 8-bit binary number. Please let me know how to improve this function, and other C-style coding conventions. Thanks! <...
Linny's user avatar
  • 9,948
3 votes
1 answer
94 views

Integer to Roman Numeral conversion

As a little standard exercise, I wrote an integer to roman numerals converter in F03. The result looks already neat enough, for my standards, but I wonder whether it could be made snappier without ...
Luca Argenti's user avatar
2 votes
1 answer
47 views

Input any time, output timezones that are currently that time

I made a program that will take in a time and a weekday, and return which parts of the world are at times closest to the one specified. Part of the program focuses on extracting a date and country out ...
Chocolate's user avatar
  • 948
5 votes
1 answer
2k views

C++ File Converter Program

Looking for input on how to clean up my code. I am writing a file converter that can read different but related file types (relatable like a wav and mp3 encode audio or how a jpg and tiff encode image ...
ChipsAhoy's user avatar
2 votes
0 answers
240 views

PowerShell - Convert English words describing numbers to their values in Arabic numeral

I am extremely new to programming, and I am a really fast learner if I am interested, I have only started using PowerShell in less than a month, to improve my programming skill, this is a script I ...
Ξένη Γήινος's user avatar
8 votes
2 answers
732 views

Binary to decimal (and back) converter in c++

I'm mainly looking for error checking / type safety advice. main.cpp ...
Nadpher's user avatar
  • 889
3 votes
2 answers
268 views

Binary to decimal

Can I make this code somehow faster and is this readable? I'm a beginner and in later I'll make another class with Decimal to Binary conversion, but first I've to know how to do that. ...
El Patron Salan's user avatar

1
2 3 4 5
8