MediaWiki API result

This is the HTML representation of the JSON format. HTML is good for debugging, but is unsuitable for application use.

Specify the format parameter to change the output format. To see the non-HTML representation of the JSON format, set format=json.

See the complete documentation, or the API help for more information.

{
    "batchcomplete": "",
    "continue": {
        "gapcontinue": "Reading_the_documentation_(in_Russian)",
        "continue": "gapcontinue||"
    },
    "query": {
        "pages": {
            "423": {
                "pageid": 423,
                "ns": 0,
                "title": "Read table data from file",
                "revisions": [
                    {
                        "contentformat": "text/x-wiki",
                        "contentmodel": "wikitext",
                        "*": "== Reading tabular data from file ==\n\nTo read in a text file with records in rows, where fields are separated by a separator (e.g. tab, whitespace), this code might help:\n\n<syntaxhighlight lang=\"D\" line highlight=\"11\">\nmodule test.read;\n\nimport std.stdio;\nimport std.array;\n\nauto readInData(File inputFile, string fieldSeparator)\n{\n    string[][] buffer;\n\n    foreach (line; inputFile.byLine)\n        buffer ~= split(line.idup, fieldSeparator);\n\n    return buffer;\n}\n\nvoid main(string[] args)\n{\n    if (args.length > 1)\n        writeln(readInData(\n            File(args[1]),\n            args.length > 2 ? args[2] : \" \"\n        ));\n}\n</syntaxhighlight>\n\n\nThe not so obvious usage of '''.idup''' property is necessary here in order to avoid memory rewrite of the output multidimensional string array.\nThere are couple of reasons for this:\n*the LineReader defined with <code>File.byLine()</code> reuses its buffer for efficiency and\n*<code>split()</code> function is optimized to return slices into its input buffer (<code>line</code> in this case) instead of copying each substring to output.\nWithout the <code>line</code> being duplicated the output buffer gets overwritten in every iteration.\n\n== Credits ==\n\nThe information provided here was first discussed on [http://forum.dlang.org/post/blciltrhymxcwpdcfrbp@forum.dlang.org this thread].\n\n[[Category:HowTo]]"
                    }
                ]
            },
            "1085": {
                "pageid": 1085,
                "ns": 0,
                "title": "Reading and writing to files",
                "revisions": [
                    {
                        "contentformat": "text/x-wiki",
                        "contentmodel": "wikitext",
                        "*": "== Reading and writing to files ==\n\nA collection of one handy snippets for reading, manipulating and writing data to files in one line.\n\n* Given a file with a single number on each line, reach only the first 10 lines, sum the total and print each number read.\n\n<syntaxhighlight lang=\"D\">\nmodule read_and_sum;\n\nimport std.conv : to;\nimport std.stdio: writeln;\nimport std.range : takeExactly, tee;\nimport std.algorithm.iteration : map, each;\n\nvoid main()\n{\n    double total = 0;\n    File(\"./10numbers.txt\")\n         // lazily iterate by line\n        .byLine\n\n         // pick first 10 lines\n        .takeExactly(10)\n         \n         // convert each to double\n        .map!(to!double)\n\n         // add element ro total\n        .tee!((x) { total += x; })\n\n        // print each number \n        .each!writeln;\n}\n</syntaxhighlight>\n\n\n[[Category:Cookbook]]"
                    }
                ]
            }
        }
    }
}