Showing posts with label function. Show all posts
Showing posts with label function. Show all posts

Sunday, March 24, 2013

Comparing and Filtering through Lists of Data

In this tutorial, similarly to the Comma Adder Tutorial, we will be reading in data and then modifying it for output into another file.

However, this time, there will be another file of data that we will compare it with. We will remove duplicates from our output, and we will keep track of those duplicates and output them to another file. So, if our input for the first file is this:

1234567
2345678
3456789

and our input from the second file is this (I've colored the duplicate blue):

8573968
3958396
1234567
3058376

Our first output file will be this (with duplicate(s) removed):

2345678
3456789

and our second output file will be this (the duplicate(s)):

1234567

Thursday, March 7, 2013

Comma Adder

In a similar fashion to my 2 previous tutorials:

http://thecodingtutorials.blogspot.com/2013/01/simple-file-manipulation-in-console.html
http://thecodingtutorials.blogspot.com/2013/01/character-arrays-in-c.html

This tutorial will show a C++ program that takes input from a file called "input.txt" and outputs it to "output.txt", only this time, it will take input like this:

1234567
1234567
1234567

and output it with commas after the third digit on each line like this:

123,4567
123,4567
123,4567

Wednesday, January 16, 2013

Simple File Manipulation in a Console Application with C++

The goal of this tutorial is to show you how to make a C++ console application that will read data from a file called "input.txt" that's formatted like this (with each new entry on its own line):

1234567
1234567
1234567

and output it to a file called "output.txt" that is formatted like this (standard CSV (Comma Separated Values) format, except with 25 columns per row maximum):

1234567,1234567,1234567,...(25 times)
1234567,1234567,1234567,...(25 times)
1234567,1234567,1234567,...(18 times)

Tuesday, July 31, 2012

Using CSV (and Text) Files with D3

This tutorial is in response to a request by someone who wanted to know how to use data from CSV (Comma Separated Values) files with D3. Interestingly enough, you will also see how the data can be stored into and read from a simple text file (instead) along the way.

The CSV file format is commonly used in spreadsheets, and it's pretty well known to programmers as one of the easiest formats to read and write data with. Why? Take a look at what a CSV file's contents could be:
2345, 345, sdfgsd, 3453,
wgdg, 34, fsg, dgd, 34534.634,

sfsfggsdfgsdfgsdfh, 4, "hello",
-2
If you look past the stupidity of the bogus "data" I used in that example, you'll see that it's fairly simplistic! Every value is separated by a comma - hence, Comma Separated Values (CSV).

Before I show you how to use CSV, you should know that I made an "Introduction to D3" tutorial earlier. I highly recommend that you read it first.

Thursday, July 26, 2012

Introduction to D3

This tutorial is in response to a request by someone who wanted a basic introduction to D3. I've never used D3 before, but I've learned a bit about it so far and this is just an introduction to get you started anyways.

Basically, what I've found is that D3 is a lot like JQuery in many regards. You can select existing (and not-yet-existing) elements, manipulate them graphically, perform animations, etc. The best aspect of D3 seems to be that although the learning curve is rather steep for anyone who's a beginning coder, it actually ends up making most tasks of displaying/arranging data on a web page very simple and easy - you just have to know how. :)

Friday, May 25, 2012

Interacting with a MySQL Database Table in PHP

Now that you can create HTML forms and receive HTTP POST data and properly set up a table in a MySQL database, you are ready for the next step: interacting with this MySQL database through the use of an HTML form. All that's left for you to know and do is run MySQL queries from PHP code. Here's the script we're going to be looking at in this tutorial:

Friday, May 18, 2012

Creating HTML Forms and Receiving HTTP POST Data

In my previous post, I showed you how to use HTTP GET to transfer/receive data through a page's URL (as well as how to intermingle PHP code with HTML code). What if you want the user to submit data through an HTML form to your website? That's where HTTP POST comes in.

There are two parts to making standard HTML forms: the HTML form code itself (including graphics, placement, text, and logic/data) and the PHP script that will retrieve the form data. We'll start with a brief overview of how you might want to make the form.

Thursday, January 12, 2012

Changing Page Content with JQuery

This tutorial is in response to a specific request by someone. Here is the summarized version of their request:

How would you use JQuery to create an image that changes when the mouse is over it and also changes the content (text/image(s)) in a different section of the page dynamically (without refreshing the page)?

In order to change page content with JQuery, you must first import JQuery and know the basics of how to use it, all of which I discussed here.


We will also need two images to test this out with and a section of content to change dynamically when the mouse moves over and out of this image. Here is the code we will use for our initial image: